def calculate_score(self, h, pos, neg, pos_score=None, neg_score=None, multipos=False):
#h_pro = self.act1(self.W_predict(h))
h_pro = h
if multipos:
# If multiple positive vectors are given,
# max score is picked up. (other ones are not propagated)
pos_scoreL = [F.batch_matmul(h_pro, pos_one, transa=True) for pos_one in pos]
pos_score = F.max(F.concat(pos_scoreL, axis=1), axis=1, keepdims=True)
else:
pos_score = F.batch_matmul(h_pro, pos, transa=True)
neg_score = F.batch_matmul(h_pro, neg, transa=True)
return pos_score, neg_score
评论列表
文章目录