import tensorflow as tf
import numpy as np

# ##Save to file
# W = tf.Variable([[4,5,6],[7,8,9]],dtype=tf.float32,name="weight")
# b = tf.Variable([[2,5,8]],dtype=tf.float32,name="biases")
#
# init = tf.initialize_all_variables()
#
# saver = tf.train.Saver()
#
# with tf.Session() as sess:
#     sess.run(init)
#     save_path = saver.save(sess,"models/model.ckpt")
#     print("save complete")

W = tf.Variable(np.arange(6).reshape((2,3)),dtype=tf.float32,name="weight")
b = tf.Variable(np.arange(3).reshape((1,3)),dtype=tf.float32,name="biases")

saver = tf.train.Saver()

with tf.Session() as sess:
    saver.restore(sess,"models/model.ckpt")
    print(sess.run(W))
    print(sess.run(b))

  

[[4. 5. 6.]
[7. 8. 9.]]
[[2. 5. 8.]]

相关文章:

  • 2021-08-28
  • 2021-04-01
  • 2022-01-23
  • 2021-12-10
  • 2021-08-25
  • 2021-05-17
猜你喜欢
  • 2021-09-27
  • 2022-12-23
  • 2021-05-04
  • 2022-02-08
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案