mindspore.ops.padding

View Source On Gitee
mindspore.ops.padding(x, pad_dim_size=8)[source]

Extends the last dimension of the input tensor from 1 to pad_dim_size, by filling with 0.

Parameters
  • x (Tensor) – The shape of tensor is \((x_1, x_2, ..., x_R)\). The rank of x must be at least 2. The last dimension of x must be 1. The data type is Number.

  • pad_dim_size (int) – The value of the last dimension of x to be extended, which must be positive. Default: 8 .

Returns

Tensor, has the same type and shape as input shape value.

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([[8], [10]]), mindspore.float32)
>>> pad_dim_size = 4
>>> output = ops.padding(x, pad_dim_size)
>>> print(output)
[[ 8.  0.  0.  0.]
 [10.  0.  0.  0.]]