DeepCTR icon indicating copy to clipboard operation
DeepCTR copied to clipboard

A merge layer should be called on a list of inputs

Open 1073521013 opened this issue 5 years ago • 2 comments

Describe the bug(问题描述) 保存模型model.save,然后加载的时候,tf.keras.models.load_model报错"A merge layer should be called on a list of inputs",官方找到类似问题说更新keras,现在最新2.4.3还是报错

To Reproduce(复现步骤) DeepFM模型完整保存,model.save()

Operating environment(运行环境):

  • python version 3.7
  • tensorflow version 2.2.0
  • keras version 2.4.3

Additional context Add any other context about the problem here.

1073521013 avatar Aug 05 '20 12:08 1073521013

请提供一份最短可复现的代码,方便我们排查问题

shenweichen avatar Dec 05 '20 07:12 shenweichen

## examples/run_classification_criteo.py

model = DeepFM(linear_feature_columns, dnn_feature_columns, task='binary')
model.compile("adam", "binary_crossentropy",
              metrics=['binary_crossentropy'], )

history = model.fit(train_model_input, train[target].values,
                    batch_size=256, epochs=10, verbose=2, validation_split=0.2, )
pred_ans = model.predict(test_model_input, batch_size=256)

print("test_model_input:", test[target].values)
print("pred_ans:", pred_ans)

model.save('./Criteo.pb')
print('#'*120)
import keras
model1=keras.models.load_model('./Criteo.pb')

报上述的那个错误,请问怎么解决呢,辛苦看下?

Operating environment(运行环境):

python version 3.8 tensorflow version 2.3.1 keras version 2.4.3

Darinyazanr avatar Jul 04 '21 03:07 Darinyazanr

这个问题解决了么?我也遇到了~

feng-intel avatar Oct 08 '22 07:10 feng-intel