错误:当前的“保存”要求模型为图形网络。无法保存模型

时间:2019-01-07 10:49:06

标签: python-3.x machine-learning deep-learning google-colaboratory

我正在使用 google colaboratory 在python3中实现深度学习。我创建一个模型,对其进行训练,测试。一切都好。最后,我尝试将模型保存在我的Google驱动器上。但是说 错误:当前“保存”要求模型为图形网络。

进行培训和测试没有问题。

然后我安装驱动器

from google.colab import drive
drive.mount('/content/gdrive')

然后尝试保存模型以供以后使用:

model.save('my_model_name.model')

但是它没有保存模型。我想念什么?

1 个答案:

答案 0 :(得分:0)

使用tensorflow保存模型的首选方法是使用tf.train.Saver()模块。因此,可以说您的模型简称为 Model ,您想将其保存在特定目录中。这是首选的方法。

import tensorflow as tf
directory_to_save = '/content/drive'
with tf.Session() as sess
    saver = tf.train.Saver()
    #train model
    saver.save(sess, directory_to_save)
相关问题