lp_pool1d¶
- paddle.nn.functional. lp_pool1d ( x: Tensor, 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 ) Tensor [source]
-
This API implements power-average pooling 1d operation. See more details in LPPool1D .
- Parameters
-
x (Tensor) – The input tensor of pooling operator which is a 3-D tensor with shape [N, C, L]. where N is batch size, C is the number of channels, L is the length of the feature. The data type is float16, float32 or float64.
norm_type (int|float) – The number the power operation.
kernel_size (int|list|tuple) – The pool kernel size. If it is a tuple or list, it must contain two integers, (kernel_size_Height, kernel_size_Width). Otherwise, the pool kernel size will be a square of an int.
stride (int|list|tuple) – The stride size. If it is a tuple or list, it must contain two integers, (stride_Height, stride_Width). Otherwise, the stride size will be a square of an int.
padding (string|int|list|tuple) – 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 2, [pad_height, pad_weight] whose value means the padding size of each dimension. 4. A list[int] or tuple(int) whose length is 4. [pad_height_top, pad_height_bottom, pad_width_left, pad_width_right] whose value means the padding size of each side. 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 detailed information, please refer to Name. Usually name is no need to set and None by default.
- Returns
-
The output tensor of pooling result. The data type is same as input tensor.
- Return type
-
Tensor
Examples
>>> import paddle >>> import paddle.nn as nn >>> data = paddle.uniform([1, 3, 32], paddle.float32) >>> LPPool1D = nn.LPPool1D(norm_type=3, kernel_size=2, stride=2, padding=0) >>> pool_out = LPPool1D(data) >>> print(pool_out.shape) [1, 3, 16]