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.
- Parameters
pad_dim_size (int) – The value of the last dimension of x to be extended, which must be positive. Default: 8.
- Inputs:
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.
- Outputs:
Tensor, the shape of tensor is \((z_1, z_2, ..., z_N)\).
- Raises
TypeError – If pad_dim_size is not an int.
ValueError – If pad_dim_size is less than 1.
ValueError – If last dim of x is not equal 1.
- Supported Platforms:
Ascend
Examples
>>> 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.]]