5.4 TensorFlow模型持久化

来源:互联网 发布:nodejs 运行js文件 编辑:程序博客网 时间:2024/06/07 10:24

1.模型的保存

import tensorflow as tfv1 = tf.Variable(tf.constant(1.0,shape=[1]),name="v1")v2 = tf.Variable(tf.constant(2.0,shape=[1]),name="v2")result = v1 + v2init_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.模型的

阅读全文
0 0
原创粉丝点击