qml.math.toarray

toarray(tensor)[source]

Returns the tensor as a NumPy ndarray. No copying is performed; the tensor and the returned array share the same storage.

Parameters

tensor (tensor_like) – input tensor

Returns

a ndarray view into the same data

Return type

array

Example

>>> x = torch.tensor([1., 2.])
>>> toarray(x)
array([1, 2])