mindspore.mint.unsqueeze

View Source On Gitee
mindspore.mint.unsqueeze(input, dim)[source]

Adds an additional dimension to the input tensor at the given dimension.

Parameters
  • input (Tensor) – The input tensor.

  • dim (int) – The dimension specified.

Returns

Tensor

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> input = mindspore.tensor([1, 2, 3, 4])
>>> mindspore.mint.unsqueeze(input, 0)
Tensor(shape=[1, 4], dtype=Int64, value=
[[1, 2, 3, 4]])
>>> mindspore.mint.unsqueeze(input, 1)
Tensor(shape=[4, 1], dtype=Int64, value=
[[1],
 [2],
 [3],
 [4]])