title: How do I get the value of a tensor in PyTorch?
body: <p>Printing a tensor <code>x</code> gives:</p>
  <pre><code>&gt;&gt;&gt; x = torch.tensor([3])
  &gt;&gt;&gt; print(x)
  tensor([3])
  </code></pre>
  <p>Indexing <code>x.data</code> gives:</p>
  <pre><code>&gt;&gt;&gt; x.data[0]
  tensor(3)
  </code></pre>
  <p>How do I get just a regular non-tensor value <code>3</code>?</p>