Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用tf.print()在张量内打印3个以上的值?_Python_Tensorflow - Fatal编程技术网

Python 如何使用tf.print()在张量内打印3个以上的值?

Python 如何使用tf.print()在张量内打印3个以上的值?,python,tensorflow,Python,Tensorflow,我有一个简单的代码,用于将张量沿轴=1拆分为三部分 sess = tf.Session() a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) x, y, z = tf.split(a, 3, axis=1) print_out_x = tf.Print(x, [x], message='Value of x: ', name='x_value') print_out_y = tf.Print(y, [y], me

我有一个简单的代码,用于将张量沿
轴=1拆分为三部分

sess = tf.Session()
a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])

x, y, z = tf.split(a, 3, axis=1)

print_out_x = tf.Print(x, [x], message='Value of x: ', name='x_value')
print_out_y = tf.Print(y, [y], message='Value of y: ', name='y_value')
print_out_z = tf.Print(z, [z], message='Value of z: ', name='z_value')

sess.run([print_out_x, print_out_y, print_out_z])

print(print_out_x)
print(print_out_y)
print(print_out_z)
我得到的输出如下

如何使用
tf.Print()
,而不是
来获取x、y、z中的全部值?更具体地说,我希望输出应该是

Value of z: [[3][6][9][12]]
Value of y: [[2][5][8][11]]
Value of x: [[1][4][7][10]]
您可以使用
tf.Print()
函数中的:
summary
,设置每个输入张量需要打印的参数数

例如

tf.Print(x, [x],summarize=x.shape[0], message='Value of x: ', name='x_value')
#Value of x: [[1][4][7][10]]
您可以使用
tf.Print()
函数中的:
summary
,设置每个输入张量需要打印的参数数

例如

tf.Print(x, [x],summarize=x.shape[0], message='Value of x: ', name='x_value')
#Value of x: [[1][4][7][10]]