torch.Tensor.numpy
- Tensor.numpy(*, force=False) → numpy.ndarray
Returns the tensor as a NumPy
ndarray.If
forceis (the default), the conversion is performed only if the tensor is on the CPU, does not require grad, does not have its conjugate bit set, and is a dtype and layout that NumPy supports. The returned ndarray and the tensor will share their storage, so changes to the tensor will be reflected in the ndarray and vice versa.