Search notes:

torch.set_printoptions

torch.set_printoptions sets options that influence representations of data and structures when printing objects: precision, threshold, edgeitem, linewidth, profile, sci_mode.
import torch

t = torch.rand(6, 12)
print(t)
#
# tensor([[0.6117, 0.0518, 0.5352, 0.0336, 0.3867, 0.4226, 0.7421, 0.6326, 0.8513,
#          0.3978, 0.9182, 0.9460],
#         [0.5390, 0.0180, 0.3681, 0.5872, 0.5608, 0.6194, 0.8782, 0.5424, 0.4247,
#          0.6658, 0.5897, 0.4290],
#         [0.8461, 0.5466, 0.4661, 0.1771, 0.7227, 0.0198, 0.6738, 0.1681, 0.0116,
#          0.1908, 0.6395, 0.7403],
#         [0.8149, 0.4018, 0.2579, 0.8491, 0.1808, 0.8019, 0.4719, 0.7264, 0.4242,
#          0.2717, 0.8367, 0.1102],
#         [0.9418, 0.5857, 0.0419, 0.4986, 0.1401, 0.7487, 0.6147, 0.8869, 0.8674,
#          0.0040, 0.5854, 0.3774],
#         [0.0518, 0.7023, 0.2591, 0.3874, 0.8995, 0.3785, 0.5094, 0.9532, 0.3413,
#          0.7080, 0.3766, 0.7444]])

torch.set_printoptions(linewidth=120)
print(t)
# 
# tensor([[0.6117, 0.0518, 0.5352, 0.0336, 0.3867, 0.4226, 0.7421, 0.6326, 0.8513, 0.3978, 0.9182, 0.9460],
#         [0.5390, 0.0180, 0.3681, 0.5872, 0.5608, 0.6194, 0.8782, 0.5424, 0.4247, 0.6658, 0.5897, 0.4290],
#         [0.8461, 0.5466, 0.4661, 0.1771, 0.7227, 0.0198, 0.6738, 0.1681, 0.0116, 0.1908, 0.6395, 0.7403],
#         [0.8149, 0.4018, 0.2579, 0.8491, 0.1808, 0.8019, 0.4719, 0.7264, 0.4242, 0.2717, 0.8367, 0.1102],
#         [0.9418, 0.5857, 0.0419, 0.4986, 0.1401, 0.7487, 0.6147, 0.8869, 0.8674, 0.0040, 0.5854, 0.3774],
#         [0.0518, 0.7023, 0.2591, 0.3874, 0.8995, 0.3785, 0.5094, 0.9532, 0.3413, 0.7080, 0.3766, 0.7444]])

torch.set_printoptions(precision=2)
print(t)
# tensor([[0.44, 0.84, 0.26, 0.46, 0.04, 0.68, 0.91, 0.38, 0.74, 0.48, 0.95, 0.19],
#         [0.72, 0.09, 0.63, 0.41, 0.81, 0.72, 0.15, 0.26, 0.66, 0.75, 0.52, 0.43],
#         [0.09, 0.16, 0.60, 0.04, 0.58, 0.89, 0.53, 0.95, 0.90, 0.23, 0.32, 0.36],
#         [0.23, 0.96, 0.50, 0.17, 0.12, 0.66, 0.98, 0.05, 0.63, 0.12, 0.43, 0.29],
#         [0.02, 0.02, 0.17, 0.03, 0.21, 0.55, 0.68, 0.86, 0.19, 0.51, 0.28, 0.26],
#         [0.34, 0.51, 0.46, 0.88, 0.68, 0.05, 0.41, 0.64, 0.82, 0.05, 0.62, 0.12]])

Index