eazygrad.from_numpy

eazygrad.from_numpy(array: numpy.ndarray, requires_grad: bool = False) _Tensor[source]

Create a tensor that shares storage with an existing NumPy array.

Parameters:
  • array (numpy.ndarray) – Source array. The tensor reuses the same underlying storage.

  • requires_grad (bool, default=False) – Whether to track operations on the returned tensor for automatic differentiation.

Returns:

_Tensor – Tensor view over array.

Raises:

Notes

Mutations are shared between the NumPy array and the returned tensor.

See also

torch.from_numpy