pytorch / 2 / generated / torch.nn.functional.fractional_max_pool3d.html

torch.nn.functional.fractional_max_pool3d

torch.nn.functional.fractional_max_pool3d(input, kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None)

Applies 3D fractional max pooling over an input signal composed of several input planes.

Fractional MaxPooling is described in detail in the paper Fractional MaxPooling by Ben Graham

The max-pooling operation is applied in k T × k H × k W kT \times kH \times kW regions by a stochastic step size determined by the target output size. The number of output features is equal to the number of input planes.

Parameters
  • kernel_size – the size of the window to take a max over. Can be a single number k k (for a square kernel of k × k × k k \times k \times k ) or a tuple (kT, kH, kW)
  • output_size – the target output size of the form o T × o H × o W oT \times oH \times oW . Can be a tuple (oT, oH, oW) or a single number o H oH for a cubic output o H × o H × o H oH \times oH \times oH
  • output_ratio – If one wants to have an output size as a ratio of the input size, this option can be given. This has to be a number or tuple in the range (0, 1)
  • return_indices – if True, will return the indices along with the outputs. Useful to pass to max_unpool3d().
Shape:
  • Input: ( N , C , T i n , H i n , W i n ) (N, C, T_{in}, H_{in}, W_{in}) or ( C , T i n , H i n , W i n ) (C, T_{in}, H_{in}, W_{in}) .
  • Output: ( N , C , T o u t , H o u t , W o u t ) (N, C, T_{out}, H_{out}, W_{out}) or ( C , T o u t , H o u t , W o u t ) (C, T_{out}, H_{out}, W_{out}) , where ( T o u t , H o u t , W o u t ) = output_size (T_{out}, H_{out}, W_{out})=\text{output\_size} or ( T o u t , H o u t , W o u t ) = output_ratio × ( T i n , H i n , W i n ) (T_{out}, H_{out}, W_{out})=\text{output\_ratio} \times (T_{in}, H_{in}, W_{in})
Examples::
>>> input = torch.randn(20, 16, 50, 32, 16)
>>> # pool of cubic window of size=3, and target output size 13x12x11
>>> F.fractional_max_pool3d(input, 3, output_size=(13, 12, 11))
>>> # pool of cubic window and target output size being half of input size
>>> F.fractional_max_pool3d(input, 3, output_ratio=(0.5, 0.5, 0.5))

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.nn.functional.fractional_max_pool3d.html