码迷,mamicode.com
首页 > 其他好文 > 详细

TF:利用TF的train.Saver载入曾经训练好的variables(W、b)以供预测新的数据

时间:2018-01-25 23:10:04      阅读:452      评论:0      收藏:0      [点我收藏+]

标签:ssi   body   分享图片   variable   pos   pre   print   res   highlight   

import tensorflow as tf
import numpy as np

W = tf.Variable(np.arange(6).reshape((2, 3)), dtype=tf.float32, name="weights")
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, "niu/save_net.ckpt") 
    print("weights:", sess.run(W))
    print("biases:", sess.run(b))

  技术分享图片

 

TF:利用TF的train.Saver载入曾经训练好的variables(W、b)以供预测新的数据

标签:ssi   body   分享图片   variable   pos   pre   print   res   highlight   

原文地址:https://www.cnblogs.com/yunyaniu/p/8353420.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!