How do I get the value of a tensor in PyTorch?
Printing a tensor x gives:
&gt;&gt;&gt; x = torch.tensor([3])
&gt;&gt;&gt; print(x)
tensor([3])

Indexing x.data gives:
&gt;&gt;&gt; x.data[0]
tensor(3)

How do I get just a regular non-tensor value 3?

You can use x.item() to get a Python number from a Tensor that has one element.
