Printing the full tensor value to the console or writing to a file in the tensor stream

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

[[[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 shadoworflow to print the whole tensor instead of cropping it with ellipses?

+4
source share
2 answers

The value returned by the TansorFlow call Session.run()is numpy ndarray, so this rendering is controlled by NumPy itself. One easy way to print all items is numpy.set_printoptions():

import numpy
numpy.set_printoptions(threshold=numpy.nan)
+3
source

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
+2
source

Source: https://habr.com/ru/post/1627998/


All Articles