def cosine(q,a):
pooled_len_1 = tf.sqrt(tf.reduce_sum(q * q, 1))
pooled_len_2 = tf.sqrt(tf.reduce_sum(a * a, 1))
pooled_mul_12 = tf.reduce_sum(q * a, 1)
score = tf.div(pooled_mul_12, pooled_len_1 * pooled_len_2 +1e-8, name="scores")
return score
帮一个同事调试代码,最后发现是他的cosine写得有问题,换成这个后好了,loss也换成IRGAN一模一样的了(都是 neg正例 和 pos负例 都有的),摘自IRGAN
https://github.com/geek-ai/irgan
参考网址:
https://blog.csdn.net/u012885320/article/details/81059915
https://blog.csdn.net/ayisha09/article/details/80397588
https://blog.csdn.net/u014365862/article/details/79948612
https://blog.csdn.net/liuchonge/article/details/70049413