算法:归一化->点积->求和,注意 tf.multiply 是元素相乘
import tensorflow as tf
# 维度 a = bs * emb_size, b = bs * emb_size
a = tf.math.l2_normalize(a, axis=1)
b = tf.math.l2_normalize(b, axis=1)
dot_product
算法:归一化->点积->求和,注意 tf.multiply 是元素相乘
import tensorflow as tf
# 维度 a = bs * emb_size, b = bs * emb_size
a = tf.math.l2_normalize(a, axis=1)
b = tf.math.l2_normalize(b, axis=1)
dot_product