- paddle.nn.functional. adaptive_avg_pool1d ( x, output_size, name=None )
Adaptive average pooling 1d operation on
See more details in api_nn_pooling_AdaptiveAvgPool1d .
x (Tensor) – The input Tensor of pooling, which is a 3-D tensor with shape \([N, C, L]\), where \(N\) is batch size, \(C\) is the number of channels and \(L\) is the length of the feature. The data type is float32 or float64.
output_size (int) – The target output size. Its data type must be int.
name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.
The result of 1D adaptive average pooling. Its data type is same as input.
- Return type
# average adaptive pool1d # suppose input data in shape of [N, C, L], `output_size` is m or [m], # output shape is [N, C, m], adaptive pool divide L dimension # of input data into m grids averagely and performs poolings in each # grid to get output. # adaptive max pool performs calculations as follow: # # for i in range(m): # lstart = floor(i * L / m) # lend = ceil((i + 1) * L / m) # output[:, :, i] = sum(input[:, :, lstart: lend])/(lstart - lend) # import paddle import paddle.nn.functional as F data = paddle.uniform([1, 3, 32]) pool_out = F.adaptive_avg_pool1d(data, output_size=16) # pool_out shape: [1, 3, 16])