Print a verbose version of a tensor?


(Michael Loster) #1

Hi, I am trying to print all elements of a tensor. If you print the tensor to the console it prints out the truncated/shortened version of a tensor like so:

0.4083 -0.9696 -0.6410  ...   0.2151  1.2099 -1.1515
-0.7183  0.2448 -1.2213  ...  -1.2962  0.8652 -0.2280
0.6181  0.3332 -0.3895  ...  -0.6494  0.8589  0.4929
          ...            ⋱             ...          
-0.6540  0.3416 -0.4859  ...   0.3065  0.5496  1.8354
-2.1232 -0.4024 -0.9904  ...   0.5035  0.2489  0.0150
-0.4863  0.3312 -0.3083  ...  -0.0798 -0.5021 -1.6110
[torch.FloatTensor of size 61x80]

Is there a way to print a verbose version of the tensor, so that it contains all elements?


(Courdier) #2

Hi!
You could use torch.set_printoptions(threshold=5000) to set the threshold higher.
See the DOC.


(Saurabh Khanduja) #4

Ideal way:-

torch.set_printoptions(profile="full")
print(tensor_name)
torch.set_printoptions(profile="default")