关于在colab中保存训练好的模型的说明
1.装载谷歌云盘
2训练模型
3保存模型执行下面代码即可(更改自己想保存的文件路径)
# Create a saver.
tf.compat.v1.disable_eager_execution()
saver = tf.compat.v1.train.Saver()
# Launch the graph and train, saving the model every 1,000 steps.
sess = tf.compat.v1.Session()
"""for step in range(1000000):
sess.run()
if step % 1000 == 0:"""
# Append the step number to the checkpoint name:
init = tf.compat.v1.global_variables_initializer()
sess.run(init)
saver.save(sess, '/content/drive/MyDrive/model/TestModel')
保存成功后目录下面出现如下文件