thunlp / Fast-TransX

An Efficient implementation of TransE and its extended models for Knowledge Representation Learning
MIT License
402 stars 108 forks source link

test_transE.cpp 中的calc_sum函数问题 #16

Closed july7vivian closed 7 years ago

july7vivian commented 7 years ago

函数如下:

float calc_sum(int e1, int e2, int rel) { 
    float res = 0;
    int last1 = e1 * relationTotal * dimensionR + rel * dimensionR;
    int last2 = e2 * relationTotal * dimensionR + rel * dimensionR;
    int lastr = rel * dimensionR;
    for (int i = 0; i < dimensionR; i++)
        res += fabs(entityVec[last1 + i] + relationVec[lastr + i] - entityVec[last2 + i]);
    return res;
}

对last1和last2的赋值不能理解

为什么不是

int last1 = e1 * dimension; int last2 = e2 * dimension;

谢谢!

THUCSTHanxu13 commented 7 years ago

应该是“int last1 = e1 dimension; int last2 = e2 dimension;”,上传的代码有些错误,我更正下 = =!