mindspore.ops.atleast_1d
- mindspore.ops.atleast_1d(inputs)[source]
Returns a one-dimensional tensor of each zero-dimensional tensor, while tensors with one or more dimensions remain unchanged.
- Parameters
inputs (Union[Tensor, list[Tensor]]) – The input tensor or list of tensors.
- Returns
Tensor or list of tensors.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> # case 1: Input is a zero-dimensional tensor. >>> x = mindspore.tensor(1) >>> mindspore.ops.atleast_1d(x) Tensor(shape=[1], dtype=Int64, value= [1]) >>> >>> # case 2: Input is a one-dimensional tensor. >>> y = mindspore.tensor([0, 1]) >>> mindspore.ops.atleast_1d(y) Tensor(shape=[2], dtype=Int64, value= [0, 1]) >>> >>> # case 3: Input is a list containing tensors of various dimensions. >>> mindspore.ops.atleast_1d([x, y]) (Tensor(shape=[1], dtype=Int64, value= [1]), Tensor(shape=[2], dtype=Int64, value= [0, 1]))