欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

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

时间:2021-06-23 09:21:56|栏目:Python代码|点击:

先上代码:

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]))

输出结果如下:

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

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

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))

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

上一篇:解决Opencv+Python cv2.imshow闪退问题

栏    目:Python代码

下一篇:详细解读Python中的__init__()方法

本文标题:解决tensorflow打印tensor有省略号的问题

本文地址:http://www.codeinn.net/misctech/146866.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有