国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

tensorflow 打印內存中的變量方法

2020-01-04 14:49:27
字體:
來源:轉載
供稿:網友

法一:

循環打印

模板

for (x, y) in zip(tf.global_variables(), sess.run(tf.global_variables())): print '/n', x, y

實例

# coding=utf-8import tensorflow as tfdef func(in_put, layer_name, is_training=True): with tf.variable_scope(layer_name, reuse=tf.AUTO_REUSE):  bn = tf.contrib.layers.batch_norm(inputs=in_put,           decay=0.9,           is_training=is_training,           updates_collections=None) return bndef main(): with tf.Graph().as_default():  # input_x  input_x = tf.placeholder(dtype=tf.float32, shape=[1, 4, 4, 1])  import numpy as np  i_p = np.random.uniform(low=0, high=255, size=[1, 4, 4, 1])  # outputs  output = func(input_x, 'my', is_training=True)  with tf.Session() as sess:   sess.run(tf.global_variables_initializer())   t = sess.run(output, feed_dict={input_x:i_p})   # 法一: 循環打印   for (x, y) in zip(tf.global_variables(), sess.run(tf.global_variables())):    print '/n', x, yif __name__ == "__main__": main()
2017-09-29 10:10:22.714213: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1052] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)<tf.Variable 'my/BatchNorm/beta:0' shape=(1,) dtype=float32_ref> [ 0.]<tf.Variable 'my/BatchNorm/moving_mean:0' shape=(1,) dtype=float32_ref> [ 13.46412563]<tf.Variable 'my/BatchNorm/moving_variance:0' shape=(1,) dtype=float32_ref> [ 452.62246704]Process finished with exit code 0

法二:

指定變量名打印

模板

print 'my/BatchNorm/beta:0', (sess.run('my/BatchNorm/beta:0'))

實例

# coding=utf-8import tensorflow as tfdef func(in_put, layer_name, is_training=True): with tf.variable_scope(layer_name, reuse=tf.AUTO_REUSE):  bn = tf.contrib.layers.batch_norm(inputs=in_put,           decay=0.9,           is_training=is_training,           updates_collections=None) return bndef main(): with tf.Graph().as_default():  # input_x  input_x = tf.placeholder(dtype=tf.float32, shape=[1, 4, 4, 1])  import numpy as np  i_p = np.random.uniform(low=0, high=255, size=[1, 4, 4, 1])  # outputs  output = func(input_x, 'my', is_training=True)  with tf.Session() as sess:   sess.run(tf.global_variables_initializer())   t = sess.run(output, feed_dict={input_x:i_p})   # 法二: 指定變量名打印   print 'my/BatchNorm/beta:0', (sess.run('my/BatchNorm/beta:0'))   print 'my/BatchNorm/moving_mean:0', (sess.run('my/BatchNorm/moving_mean:0'))   print 'my/BatchNorm/moving_variance:0', (sess.run('my/BatchNorm/moving_variance:0'))if __name__ == "__main__": main()
2017-09-29 10:12:41.374055: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1052] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)my/BatchNorm/beta:0 [ 0.]my/BatchNorm/moving_mean:0 [ 8.08649635]my/BatchNorm/moving_variance:0 [ 368.03442383]Process finished with exit code 0

以上這篇tensorflow 打印內存中的變量方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到python教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富蕴县| 富平县| 新蔡县| 湄潭县| 米易县| 中西区| 嘉黎县| 曲阜市| 汾阳市| 英山县| 麦盖提县| 晋城| 晋城| 昭通市| 扎囊县| 苍山县| 石城县| 侯马市| 盐津县| 黄浦区| 池州市| 依兰县| 永吉县| 美姑县| 建湖县| 安多县| 莎车县| 大石桥市| 汉中市| 嘉义市| 连南| 长春市| 精河县| 无极县| 康平县| 老河口市| 静安区| 桂阳县| 从化市| 静乐县| 辰溪县|