mindspore.ops.Padding

class mindspore.ops.Padding(pad_dim_size=8)[source]

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

Refer to mindspore.ops.padding() for more details.

Parameters

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

Inputs:
  • x (Tensor) - Input Tensor of 2D or higher-dimensional. The last dimension of x must be 1. The data type is Number.

Outputs:

Tensor, the padded Tensor.

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(pad_dim_size)(x)
>>> print(output)
[[ 8.  0.  0.  0.]
 [10.  0.  0.  0.]]