Pytorch: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead : <p>I have an error in my code which is not getting fixed any which way I try.</p>

<p>The Error is simple, I return a value:</p>

<pre><code>torch.exp(-LL_total/T_total)
</code></pre>

<p>and get the error later in the pipeline:</p>

<pre><code>RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.
</code></pre>

<p>Solutions such as <code>cpu().detach().numpy()</code> give the same error.</p>

<p>How could I fix it? Thanks.</p>
