PyTorch 2 · Tensors
Convert to and from NumPy
Share memory with NumPy arrays on the CPU.
t = torch.from_numpy(arr)
arr = t.numpy()
Official PyTorch 2 documentation
PyTorch 2 · Tensors
Share memory with NumPy arrays on the CPU.
t = torch.from_numpy(arr)
arr = t.numpy()
Official PyTorch 2 documentation
Was this page helpful?