latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.from_numpy
- tensorplay.from_numpy(ndarray) Tensor
Creates a
Tensorfrom anumpy.ndarray.The returned tensor and
ndarrayshare the same memory. Modifications to the tensor will be reflected in thendarrayand vice versa. The returned tensor is not resizable.It currently accepts
ndarraywith dtypes ofnumpy.float64,numpy.float32,numpy.float16,numpy.complex64,numpy.complex128,numpy.int64,numpy.int32,numpy.int16,numpy.int8,numpy.uint8, andbool.Warning
Writing to a tensor created from a read-only NumPy array is not supported and will result in undefined behavior.
Example:
>>> a = numpy.array([1, 2, 3]) >>> t = tensorplay.from_numpy(a) >>> t tensor([ 1, 2, 3]) >>> t[0] = -1 >>> a array([-1, 2, 3])
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

