将张量的全部值打印到控制台中或写入张量流中的文件 [英] Print full value of tensor into console or write to file in tensorflow

查看:302
本文介绍了将张量的全部值打印到控制台中或写入张量流中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在控制台中打印一个大张量([32,32,3]),我只能得到这样的输出:

I need to print a large tensor ([32,32,3]) into the console, and I only get output like this:

[[[245 245 245]
[245 245 245]
[245 245 245]
..., 
[245 245 245]
[245 245 245]
[245 245 245]]

[[245 245 245]
[245 245 245]
[245 245 245]
..., 
[245 245 245]
[245 245 245]
[245 245 245]]

[[245 245 245]
[245 245 245]
[245 245 245]
..., 
[245 245 245]
[245 245 245]
[245 245 245]]

..., 
[[245 245 245]
[245 245 245]
[245 245 245]
..., 
[245 245 245]
[245 245 245]
[245 245 245]]

[[245 245 245]
[245 245 245]
[245 245 245]
..., 
[245 245 245]
[245 245 245]
[245 245 245]]

[[245 245 245]
[245 245 245]
[245 245 245]
..., 
[245 245 245]
[245 245 245]
[245 245 245]]]

如何获取张量流以打印出整个张量,而不是用省略号将其截断?

How can I get tensorflow to print out the entire tensor, instead of truncating it with the ellipses?

推荐答案

从TensorFlow返回的值

The value returned from a TensorFlow Session.run() call is a NumPy ndarray, so this rendering is controlled by NumPy itself. One simple way to ensure that all elements are printed is to use numpy.set_printoptions():

import numpy
numpy.set_printoptions(threshold=numpy.nan)

这篇关于将张量的全部值打印到控制台中或写入张量流中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆