标签:bsp oba 天下 class tensor ssi nbsp initial run
note:
if you‘ll load data,the data shape should be similar with saved data‘s shape. -- 中式英语,天下无敌
import tensorflow as tf import numpy as np # save variable data W = tf.Variable([[2, 3], [3, 4]], dtype=tf.float32) b = tf.Variable([[3, 4]], dtype=tf.float32) init = tf.global_variables_initializer() saver = tf.train.Saver() with tf.Session() as sess: sess.run(init) saver_path = saver.save(sess, ‘templates/save_net.ckpt‘) print("save path in --", saver_path) # load saved Variable‘s data W = tf.Variable(np.arange(2).reshape((1, 2)), dtype=tf.float32) # 2, 2) 二行两列 b = tf.Variable(np.arange(2).reshape((2, 2)), dtype=tf.float32) # (1, 2) 一行两列 saver = tf.train.Saver() with tf.Session() as sess: saver.restore(sess, ‘templates/save_net.ckpt‘) print("W: ", sess.run(W)) print("b: ", sess.run(b))
tensorflow data's save and load
标签:bsp oba 天下 class tensor ssi nbsp initial run
原文地址:https://www.cnblogs.com/tangpg/p/9223470.html