tensorflow训练权重的保存和读取
来源:互联网 发布:结婚纪念日 礼物 知乎 编辑:程序博客网 时间:2024/05/24 07:10
'''import tensorflow as tf#Prepare to feed input, i.e. feed_dict and placeholdersw1 = tf.placeholder("float", name="w1")w2 = tf.placeholder("float", name="w2")b1= tf.Variable(2.0,name="bias")feed_dict ={w1:4,w2:8}#Define a test operation that we will restorew3 = tf.add(w1,w2)w4 = tf.multiply(w3,b1,name="op_to_restore")sess = tf.Session()sess.run(tf.global_variables_initializer())#Create a saver object which will save all the variablessaver = tf.train.Saver()#Run the operation by feeding inputprint (sess.run(w4,feed_dict))#Prints 24 which is sum of (w1+w2)*b1 #Now, save the graphsaver.save(sess, 'D:/a_ssd/',global_step=1000)'''import tensorflow as tfsess=tf.Session() #First let's load meta graph and restore weightssaver = tf.train.import_meta_graph('-1000.meta')saver.restore(sess,tf.train.latest_checkpoint('./'))# Access saved Variables directlyprint(sess.run('bias:0'))# This will print 2, which is the value of bias that we saved# Now, let's access and create placeholders variables and# create feed-dict to feed new datagraph = tf.get_default_graph()w1 = graph.get_tensor_by_name("w1:0")w2 = graph.get_tensor_by_name("w2:0")feed_dict ={w1:13.0,w2:17.0}#Now, access the op that you want to run. op_to_restore = graph.get_tensor_by_name("op_to_restore:0")print( sess.run(op_to_restore,feed_dict))
阅读全文
1 0
- tensorflow训练权重的保存和读取
- tensorflow存储图和训练的权重为.pb,然后读取.pb并使用
- tensorflow保存图和权重
- tensorflow训练权重保存和调用——tf.saver()
- 6.TensorFlow模型的保存和读取
- TensorFlow训练的模型参数(W和B)利用np.savez()保存和用cnpy库C++读取
- tensorflow选择性读取权重
- TensorFlow 训练好模型参数的保存和恢复代码
- Tensorflow保存和读取模型
- 保存和读取 TensorFlow 模型
- tensorflow在训练的时候权重是nan,如何解决
- TensorFlow保存和加载训练模型
- TensorFlow保存和加载训练模型
- TensorFlow保存和加载训练模型
- TensorFlow学习笔记--网络模型的保存和读取
- Tensorflow的模型保存和读取tf.train.Saver
- 存储图和训练好的权重
- TensorFlow模型文件保存和读取
- 2017-7-20下班随笔
- spring JdbcTemplate 和 spring mybatis 的 update方法的返回值是 Rows matched 不是 rows affected(或者Changed)
- Handler原理剖析
- 解析c++动态内存管理
- springboot包扫描导致的问题
- tensorflow训练权重的保存和读取
- opencv形态学操作函数morphologyEx
- webSocket 有点坑
- oracle script
- mybatis中#{}报错 Parameter index out of range (1 > number of parameters, which is 0)问题
- Unity3d热更新全书-加载(二)如何在不用AssetBundle的前提下动态加载预设
- Soldier
- maven-war-plugin
- HIbernate——list和iterator的区别