numpy

Applicable Products

Product

Supported (Yes/No)

Ascend 950PR/Ascend 950DT

No

Atlas A3 training products/Atlas A3 inference products

Yes

Atlas A2 training products/Atlas A2 inference products

Yes

Atlas 200I/500 A2 inference products

No

Atlas inference products

No

Atlas training products

No

Note: For the Atlas A2 training products/Atlas A2 inference products, only the Atlas 800I A2 inference server and A200I A2 Box heterogeneous subrack are supported.

Function Description

Obtains the NumPy data of a tensor.

Prototype

1
numpy(copy=False)

Parameters

Parameter

Data Type

Value Description

copy

bool

The value can be False or True.

The default value is False, indicating that tensors are converted into numpy.ndarray and data is not copied. If the value is True, data needs to be copied.

If the tensor is of the string type, set this parameter to True. Otherwise, an exception is thrown.

Example

1
2
tensor = Tensor(numpy.array([1]))
np_arr = tensor.numpy()

Returns

Returns numpy.array.

Constraints

None