adaptive_avg_pool3d¶
- paddle.nn.functional. adaptive_avg_pool3d ( x, output_size, data_format='NCDHW', name=None ) [source]
-
This operation applies 3D adaptive avg pooling on input tensor. The h and w dimensions of the output tensor are determined by the parameter output_size.
For avg adaptive pool3d:
dstart=floor(i∗Din/Dout)dend=ceil((i+1)∗Din/Dout)hstart=floor(j∗Hin/Hout)hend=ceil((j+1)∗Hin/Hout)wstart=floor(k∗Win/Wout)wend=ceil((k+1)∗Win/Wout)Output(i,j,k)=∑Input[dstart:dend,hstart:hend,wstart:wend](dend−dstart)∗(hend−hstart)∗(wend−wstart)- Parameters
-
x (Tensor) – The input tensor of adaptive avg pool3d operator, which is a 5-D tensor. The data type can be float32, float64.
output_size (int|list|tuple) – The pool kernel size. If pool kernel size is a tuple or list, it must contain three elements, (D, H, W). D, H and W can be either a int, or None which means the size will be the same as that of the input.
data_format (str, optional) – The data format of the input and output data. An optional string from: “NCDHW”, “NDHWC”. The default is “NCDHW”. When it is “NCDHW”, the data is stored in the order of: [batch_size, input_channels, input_depth, input_height, input_width].
name (str, optional) – For detailed information, please refer to Name. Usually name is no need to set and None by default.
- Returns
-
Tensor, The output tensor of avg adaptive pool3d result. The data type is same as input tensor.
Examples
# adaptive avg pool3d # suppose input data in shape of [N, C, D, H, W], `output_size` is [l, m, n], # output shape is [N, C, l, m, n], adaptive pool divide D, H and W dimensions # of input data into l * m * n grids averagely and performs poolings in each # grid to get output. # adaptive avg pool performs calculations as follow: # # for i in range(l): # for j in range(m): # for k in range(n): # dstart = floor(i * D / l) # dend = ceil((i + 1) * D / l) # hstart = floor(j * H / m) # hend = ceil((j + 1) * H / m) # wstart = floor(k * W / n) # wend = ceil((k + 1) * W / n) # output[:, :, i, j, k] = # avg(input[:, :, dstart:dend, hstart: hend, wstart: wend]) import paddle input_data = paddle.randn(shape=(2, 3, 8, 32, 32)) out = paddle.nn.functional.adaptive_avg_pool3d( x = input_data, output_size=[3, 3, 3]) # out.shape is [2, 3, 3, 3, 3]