def score_cbow_labeled_pair(model, targets, l1):
if model.hs:
prob = []
# FIXME this cycle should be executed internally in numpy
for target in targets:
l2a = model.syn1[target.point]
sgn = (-1.0) ** target.code # ch function, 0-> 1, 1 -> -1
prob.append(prod(expit(sgn * dot(l1, l2a.T))))
# Softmax
else:
def exp_dot(x):
return exp(dot(l1, x.T))
prob_num = exp_dot(model.syn1neg[[t.index for t in targets]])
prob_den = np_sum(apply_along_axis(exp_dot, 1, model.syn1neg))
prob = prob_num / prob_den
return prob
评论列表
文章目录