mindspore.ops.atleast_3d

View Source On Gitee
mindspore.ops.atleast_3d(inputs)[source]

Returns a 3-dimensional tensor of each tensor, while tensors with three 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_3d(x)
Tensor(shape=[1, 1, 1], dtype=Int64, value= [[[1]]])
>>>
>>> # case 2: Input is a 3-dimensional tensor.
>>> y = mindspore.tensor([[[0, 1], [2, 3]]])
>>> mindspore.ops.atleast_3d(y)
Tensor(shape=[1, 2, 2], dtype=Int64, value=
[[[0, 1],
  [2, 3]]])
>>>
>>> # case 3: Input is a list containing tensors of various dimensions.
>>> mindspore.ops.atleast_3d([x, y])
(Tensor(shape=[1, 1, 1], dtype=Int64, value=
 [[[1]]]),
 Tensor(shape=[1, 2, 2], dtype=Int64, value=
 [[[0, 1],
   [2, 3]]])