Reputation: 915
Is there a way to print the output of a CNN model evaluation to 2dp given that the output is a multi element FloatTensor?
eg.
prediction = torch.exp(model(image2))
print(prediction)
Out:
Variable containing:
2.84e-01 1.68e-07 7.16e-01
[torch.FloatTensor of size 1x3]
It would be better if I could output the value as:
Variable containing:
0.28 0.00 0.72
[torch.FloatTensor of size 1x3]
I've tried:
print("%.2f" % prediction)
and using:
torch.set_printoptions(precision=2)
But neither give the desired effect.
I had a look on the documentation page:
http://pytorch.org/docs/master/torch.html#creation-ops
...under 'torch.set_printoptions' but I can't see how any of the arguments might help in this situation.
Many thanks in advance!
Upvotes: 3
Views: 1121
Reputation: 7302
This has now been implemented. Use
torch.set_printoptions(sci_mode=False)
https://pytorch.org/docs/stable/torch.html#torch.set_printoptions
Upvotes: 5