在din中加入fm 无法保存tf模型问题
作者: hepengfei-ml创建于 2021年2月5日更新于 2022年11月3日
标签to be solvedquestion
运行 run_din.py,在 din.py 中添加以下代码:
din_logit = tf.keras.layers.Dense(1, use_bias=False,
kernel_initializer=tf.keras.initializers.glorot_normal(seed))(output)
sparse_feature_fm = embedding_lookup(embedding_dict, features, sparse_feature_columns, to_list=True)
fm_logit = FM()(concat_func(sparse_feature_fm, axis=1))
final_logit = add_func([fm_logit, din_logit])
output = PredictionLayer(task)(final_logit)
训练模型没有问题。但是保存时会出现以下错误:
ValueError: Dimension 0 in both shapes must be equal, but are 4 and 1. Shapes are [4] and [1]. for 'model/concatenate/concat_1' (op: 'ConcatV2') with input shapes: [?,1,4], [?,1,4], [?,1,1], [?,1,1], [] and with computed input tensors: input[4] = <1>。
内容来源: shenweichen/DeepCTR