numpy

Applicable Products

Product

Supported

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

x

Atlas inference products

x

Atlas training products

x

Function Description

Converts a tensor into an ndarray of NumPy.

Prototype

1
numpy(copy=False)

Parameters

Parameter

Data Type

Value Description

copy

bool

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 reported.

Returns

numpy.array is returned.

The DfException exception is reported in abnormal scenarios. You can obtain error_code and message in DfException to view the error code and error information. For details, see DataFlow Error Codes.

Examples

1
2
tensor = Tensor(1)
array = tensor.numpy()

Constraints

None