LPPool1D

class paddle.nn. LPPool1D ( norm_type: float, kernel_size: Size1, stride: Size1 | None = None, padding: _PaddingSizeMode | Size1 | Size2 = 0, ceil_mode: bool = False, data_format: DataLayout1D = 'NCL', name: str | None = None ) [source]

Performing a 1D power-average pooling over an input signal composed of several input planes, based on the input, output_size, return_mask parameters. Input(X) and output(Out) are in NCL format, where N is batch size, C is the number of channels, L is the length of the feature. The output tensor shape will be [N, C, output_size].

The output value of the layer with input size (N, C, L), output (N, C, \(L_{out}\)) and kernel_size ksize can be precisely described as For average pool1d:

\[Output(N_i, C_i, l) = sum(Input[N_i, C_i, stride \times l:stride \times l+k]^{norm\_type})^{1/norm\_type}\]
Parameters
  • norm_type (int|float) – The number the power operation.

  • kernel_size (int|list|tuple) – The pool kernel size. If pool kernel size is a tuple or list, it must contain an integer.

  • stride (int|list|tuple|None, optional) – The pool stride size. If pool stride size is a tuple or list, it must contain an integer. Default None, then stride will be equal to the kernel_size.

  • padding (str|int|list|tuple, optional) – The padding size. Padding could be in one of the following forms. 1. A string in [‘valid’, ‘same’]. 2. An int, which means the feature map is zero padded by size of padding on every sides. 3. A list[int] or tuple(int) whose length is 1, which means the feature map is zero padded by the size of padding[0] on every sides. 4. A list[int] or tuple(int) whose length is 2. It has the form [pad_before, pad_after]. 5. A list or tuple of pairs of integers. It has the form [[pad_before, pad_after], [pad_before, pad_after], …]. Note that, the batch dimension and channel dimension should be [0,0] or (0,0). The default value is 0.

  • ceil_mode (bool, optional) – When True, it will use ceil instead of floor to compute the output shape. Default: False.

  • data_format (str, optional) – The data format of the input and output data. An optional string from: “NCL”, “NLC”. When it is “NCL”, the data is stored in the order of: [batch_size, input_channels, input_length]. Default: “NCL”

  • name (str|None, optional) – For eed to detailed information, please refer to Name. Usually name is no nset and None by default.

Shape:
  • x(Tensor): The input tensor of lp pool1d operator, which is a 3-D tensor. The data type can be float32, float64.

  • output(Tensor): The output tensor of lp pool1d operator, which is a 3-D tensor. The data type is same as input x.

Returns

A callable object of LPPool1D.

Examples

>>> import paddle
>>> import paddle.nn as nn

>>> data = paddle.uniform([1, 3, 32], dtype="float32", min=-1, max=1)
>>> LPPool1D = nn.LPPool1D(norm_type=2, kernel_size=2, stride=2, padding=0)
>>> pool_out = LPPool1D(data)
>>> print(pool_out.shape)
[1, 3, 16]
forward ( x: Tensor ) Tensor

forward

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

extra_repr ( ) str

extra_repr

Extra representation of this layer, you can have custom implementation of your own layer.