网络编程
位置:首页>> 网络编程>> Python编程>> 解决tensorflow打印tensor有省略号的问题

解决tensorflow打印tensor有省略号的问题

作者:独孤的大山猫  发布时间:2022-12-13 09:22:09 

标签:tensorflow,tensor,省略号

先上代码:


import tensorflow as tf
x = tf.ones(shape=[100, 200], dtype=tf.int32, name='x')
y = tf.zeros(shape=[2, 3], dtype=tf.float32, name='y')
with tf.Session() as sess:
 print(sess.run([x, y]))

输出结果如下:

解决tensorflow打印tensor有省略号的问题

如果我调试的时候想查看省略号代表的值是什么

只需要改成如下代码就行:


import tensorflow as tf
import numpy as np #借助numpy模块的set_printoptions()函数,将打印上限设置为无限即可
np.set_printoptions(threshold=np.inf)
x = tf.ones(shape=[10, 20], dtype=tf.int32, name='x')
y = tf.zeros(shape=[2, 3], dtype=tf.float32, name='y')
with tf.Session() as sess:
 print(sess.run(x, y))

输出结果如下:可以看到省略号的部分也都打出来了

解决tensorflow打印tensor有省略号的问题

来源:https://blog.csdn.net/xiqi4145/article/details/89293994

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com