5.4 TensorFlow模型持久化

1.模型的保存

import tensorflow as tf
v1 = tf.Variable(tf.constant(1.0,shape=[1]),name="v1")
v2 = tf.Variable(tf.constant(2.0,shape=[1]),name="v2")
result = v1 + v2
init_op = tf.initialize_all_variables()
saver = tf.train.Saver()
with tf.Session() as sess:
	sess.run(init_op)
	saver.save(sess,"model/model.ckpt")

上面的代码共有三个变量 result = v1 + v2

使用了一个核心类 tf.train.Saver()

生成了四个文件checkpoint,model.ckpt.meta和model.ckpt.data-00000-of-00001,model.ckpt.index

2.模型的

posted @ 2017-10-25 12:02  开往春天的拖拉机  阅读(93)  评论(0编辑  收藏  举报