保存嵌套模型时,“ListWrapper”对象没有属性“get\u config”错误

2024-09-30 22:19:48 发布

您现在位置:Python中文网/ 问答频道 /正文

在Tensorflow 2.3.0上,我使用了Tensorflow Keras WideDeep model,调用model.save(path)时出现了问题

我收到的错误是 AttributeError: 'ListWrapper' object has no attribute 'get_config'

我已经用其他模型测试了我的代码,save函数工作正常

我还注意到tensorflow.keras.utils.plot_model(model, path+f'{modelName}.png', show_shapes=True, rankdir='TB', expand_nested=True)不呈现图形

原始模型使用tensorflow.keras LinearModel(宽模型)和DNN(深模型)After reading this link,我已经尝试了取出宽深和线性的Keras模型,并将其重建为功能嵌套模型。我的新设置有一个类似的错误AttributeError: 'ListWrapper' object has no attribute '_HAS_AGGREGATE_GRAD'

我认为我的错误与将多个输入作为列表传递给嵌套模型有关。有没有人有过类似的经验来保存Tensorflow Keras WideDeep或功能嵌套模型

A link to a copy of my code. The error message is presented in "Evaluate Network:Test Model"

多谢各位


Tags: pathno模型modelobjectsavetensorflow错误
1条回答
网友
1楼 · 发布于 2024-09-30 22:19:48

首先,很抱歉我的回答不专业

我也有这个问题

如果您的列车功能1为train_feature_1,则

而不是model.fit( [train_feature_1, train_feature_2], [train_label_1, train_label_2], epochs = 2 )

[np.array(train_feature_1), np.array(train_feature_2)]放在model.fit(~~~)

相关问题 更多 >