pytorch_pfn_extras.from_ndarray#
- pytorch_pfn_extras.from_ndarray(ndarray)#
Creates a torch.Tensor from a numpy.ndarray or cupy.ndarray.
Unlike torch.from_numpy, this method may make a copy when needed, e.g. when the given ndarray contains the negative strides which is not supported by PyTorch.
- Parameters:
ndarray (Any) –
- Return type:
Tensor