Jump to content

PyTorch: Difference between revisions

No change in size ,  27 January 2021
Line 75: Line 75:
* For non-scalar items, use <code>my_var.detach().cpu().numpy()</code>
* For non-scalar items, use <code>my_var.detach().cpu().numpy()</code>


* [https://pytorch.org/docs/stable/autograd.html#torch.Tensor.detach <code>detach()</code> ]deletes the item from the autograd edge.
* [https://pytorch.org/docs/stable/autograd.html#torch.Tensor.detach <code>detach()</code>] removes the item from the autograd edge.
* [https://pytorch.org/docs/stable/tensors.html?highlight=cpu#torch.Tensor.cpu <code>cpu()</code>] moves the tensor to the CPU.
* [https://pytorch.org/docs/stable/tensors.html?highlight=cpu#torch.Tensor.cpu <code>cpu()</code>] moves the tensor to the CPU.
* [https://pytorch.org/docs/stable/tensors.html#torch.Tensor.numpy <code>numpy()</code>] returns a numpy view of the tensor.
* [https://pytorch.org/docs/stable/tensors.html#torch.Tensor.numpy <code>numpy()</code>] returns a numpy view of the tensor.