【问题标题】:Trained model cannot be saved tensorflow keras训练模型无法保存 tensorflow keras
【发布时间】:2020-08-02 09:27:31
【问题描述】:

我无法在 tensorflow 中保存经过训练的模型

我已经拟合了数据

results = model.fit_generator(train_image_gen,epochs=20,validation_data=test_image_gen,callbacks=early_stop)

并导入

from tensorflow.keras.models import load_model

并写了这样的代码

save1= results.history
save1.save('model.h5')

但它会抛出这样的错误

AttributeError                            Traceback (most recent call last)
<ipython-input-47-13cfa06fe0cd> in <module>
----> 1 save1.save('model.h5')

AttributeError: 'dict' object has no attribute 'save'

我不知道如何保存此模型,还请帮助我如何将其保存在 yaml 文件中

ps:-我正在研究 kaggle

【问题讨论】:

    标签: python tensorflow keras neural-network


    【解决方案1】:

    TensorFlow 中保存模型时。您在模型上调用 save 方法,而不是在从 fit or fit_generator 返回的 history 对象上。

    请使用这个

      model.save('model.h5')
    

    【讨论】:

      猜你喜欢
      • 2019-01-20
      • 2020-09-01
      • 2023-02-22
      • 2020-01-03
      • 1970-01-01
      • 2018-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多