简体   繁体   English

训练后的 model 无法保存 tensorflow keras

[英]Trained model cannot be saved tensorflow keras

I cannot save a trained model in tensorflow我无法在 tensorflow 中保存经过训练的 model

i have fitted data我已经拟合了数据

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

and imported并进口

from tensorflow.keras.models import load_model

and written a code like this并写了这样的代码

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

but it throws an error like this但它会引发这样的错误

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

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

i can't figure out what to do to save this model please also help me how to save this in yaml file我不知道该怎么做才能保存这个 model 请也帮助我如何将它保存在 yaml 文件中

ps:-i am working on kaggle ps:-我正在研究 kaggle

when saving model in TensorFlow .在 TensorFlow 中保存TensorFlow时。 You call the save method on the model it's self not on the history object returned from fit or fit_generator .您在 model 上调用save方法,它本身不在从fit or fit_generator返回的history object 上。

Kindly use this请用这个

  model.save('model.h5')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在Tensorflow估算器中训练Keras预训练模型 - Cannot Train Keras Pre-trained Model in Tensorflow Estimator 加载由 tensorflow 训练的 Keras 模型时出错 - Error when loading Keras model trained by tensorflow 无法记录使用Keras构建但使用Tensorflow的Estimator训练的模型的损失 - Cannot log the loss from a model built with Keras but trained with Tensorflow's Estimator 如何使用从训练过的keras模型中提取的张量流模型 - How to use a tensorflow model extracted from a trained keras model Tensorflow如何修改保存为检查点的预训练模型 - Tensorflow how to modify a pre-trained Model saved as checkpoints 如何将使用 Keras model 训练的 Tensorflow 2.* 转换为.onnx 格式? - How to convert Tensorflow 2.* trained with Keras model to .onnx format? 向训练有素的 tensorflow keras model 添加重新缩放层(或任何层) - Adding a rescaling layer (or any layer for that matter) to a trained tensorflow keras model 从经过训练的模型(Python)中提取拟合的输出(KERAS / TensorFlow) - Extract fitted output from the trained model in Python (KERAS/TensorFlow) 训练 model 后,从 Keras/Tensorflow 获取预测 - Get predictions from Keras/Tensorflow once model is trained 将 Keras 模型导出为 TF Estimator:找不到经过训练的模型 - Exporting a Keras model as a TF Estimator: trained model cannot be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM