How to access the Tensor value?

Question:

I am very new to Pytorch. While finding the value of a variable, this is how it shows

tensor(0.94091, device='cuda:0')

How to access the number, i.e, 0.94091?

Asked By: Learner

||

Answers:

you can use .item() to get the value of size one tensor.

Answered By: Milad Yousefi
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.