mindspore.ops.ScalarToArray
- class mindspore.ops.ScalarToArray(*args, **kwargs)[source]
Converts a scalar to a Tensor.
- Inputs:
input_x (Union[int, float]) - The input is a scalar. Only constant value is allowed.
- Outputs:
Tensor. 0-D Tensor and the content is the input.
- Raises
TypeError – If input_x is neither int nor float.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> op = ops.ScalarToArray() >>> input_x = 1.0 >>> print(type(input_x)) <class 'float'> >>> output = op(input_x) >>> print(type(output)) <class 'mindspore.common.tensor.Tensor'> >>> print(output) 1.0