tensorflow: 打印内存中的变量
来源:互联网 发布:linux怎么批量删除文件 编辑:程序博客网 时间:2024/05/16 19:43
法一:
循环打印
模板
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
阅读全文
1 0
- tensorflow: 打印内存中的变量
- 【tensorflow】打印Tensorflow graph中的所有变量--tf.trainable_variables()
- Tensorflow中的变量初始化函数
- 83、Tensorflow中的变量管理
- 打印linx 中的environ变量
- 内存中的变量
- tensorflow中的变量和占位符
- xcode 打印内存中的值
- JavaScript 中的数据&变量&内存
- Tensorflow 变量
- 如何使用gdb打印Eigen中的变量
- gdb如何打印程序中的stl变量
- 查看TensorFlow checkpoint文件中的变量名和对应值
- 查看tensorflow ckpt文件中的变量名和对应值
- 查看tensorflow ckpt文件中的变量名和对应值
- C#使用Runtime.InteropServices打印变量的内存地址
- Tensorflow 在训练中的内存溢出以及线程安全问题
- TensorFlow打印tensor值
- SpringBoot MyBatis基础配置
- postman的使用
- 杭电acm2041:递归楼梯
- 挑战程序竞赛系列(88):3.6平面扫描(2)
- [转-qq_34531925]Webuploader教程(一)——简单实用上传功能
- tensorflow: 打印内存中的变量
- Java实现BASE64Decoder编写加密和解码
- iPhone8 和 X 买哪个?听我的
- 程序员 挣钱比健康重要
- 前端小白到技术专家,可能么?
- 阿里巴巴开源项目: 基于mysql数据库binlog的增量订阅&消费
- vuex2.0源码分析
- laravel CURD ORM
- windows server 2008系统中修改mysql数据库路径datadi后无法启动问题