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?
[A]: To print the value of a tensor without returning it to your Python program, you can use the tf. print() operator, as Andrzej suggests in another answer.
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)
use numpy.savetxt
:
x = y = z = np.arange(0.0,5.0,1.0)
np.savetxt('test.out', x, delimiter=',') # X is an array
np.savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays
np.savetxt('test.out', x, fmt='%1.4e') # use exponential notation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With