shenweichen / DeepCTR

Easy-to-use,Modular and Extendible package of deep-learning based CTR models .
https://deepctr-doc.readthedocs.io/en/latest/index.html
Apache License 2.0
7.54k stars 2.21k forks source link

din模型训练成功并且能保存pb模型但是无法加载训练好的pb模型 #491

Open hjl150505 opened 2 years ago

hjl150505 commented 2 years ago

Please refer to the FAQ in doc and search for the related issues before you ask the question.

Describe the question(问题描述) 运行: if name == "main": x, y, feature_columns, behavior_feature_list = get_xy_fd() model = DIN(feature_columns, behavior_feature_list)

model = BST(feature_columns, behavior_feature_list,att_head_num=4)

model.compile('adam', 'binary_crossentropy',
              metrics=['binary_crossentropy'])
history = model.fit(x, y, verbose=1, epochs=10, validation_split=0.5)  # 训练成功
model.save("./mydinModel")  # 可以正常保存
reloadModel = models.load_model("mydinModel")  # 此处报错

报错信息: `ValueError: Could not find matching function to call loaded from the SavedModel. Got: Positional arguments (2 total):

Expected these arguments to match one of the following 8 option(s):

Option 1: Positional arguments (2 total):

Option 2: Positional arguments (2 total):

Option 3: Positional arguments (2 total):

Option 4: Positional arguments (2 total):

Option 5: Positional arguments (2 total):

Option 6: Positional arguments (2 total):

Option 7: Positional arguments (2 total):

Option 8: Positional arguments (2 total):

Process finished with exit code 1 `

Additional context Add any other context about the problem here.

Operating environment(运行环境):

shuDaoNan9 commented 2 years ago

其他模型也有类似情况,PB格式模型用tensorflow.python.keras.models.load_model加载的时候就报这个,用Java等语言加载则正常;如果还是用Python处理的话H5格式模型我这边加载正常。

chentao169 commented 1 year ago

https://github.com/shenweichen/DeepCTR/blob/master/docs/source/FAQ.md pass in custom_objects when loading model load_model(model_path, custom_objects)