shenweichen / DeepMatch

A deep matching model library for recommendations & advertising. It's easy to train models and to export representation vectors which can be used for ANN search.
https://deepmatch.readthedocs.io/en/latest/
Apache License 2.0
2.19k stars 525 forks source link

utils.py的inner product实现有问题 #93

Open CaoYiwei opened 1 year ago

CaoYiwei commented 1 year ago

inner product是通过tf.reduce_sum实现的,reduce时候没有指定维度,建议默认axis=-1

当前0.3.1版本dssm模型无法构建,按如下方式修改后可以正常训练。

def inner_product(x, y, temperature=1.0, axis=-1): return Lambda(lambda x: tf.reduce_sum(tf.multiply(x[0], x[1]), axis) / temperature)([x, y])