MaxPool2dSamePadding

class MaxPool2dSamePadding(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

A MaxPooling which also accepts ‘same’ as valid padding to calculate the necessary padding during forward.

Note

Possible loss of throughput if padding='same' due to the additional padding calculation

See also

torch.nn.modules.pooling.MaxPool2d

Parameters:
  • kernel_size (int or iterable) – the size of the window to take a max over
  • stride (int or iterable) – the stride of the window. Default value is same as kernel_size
  • padding (int or iterable) – implicit zero padding to be added on both sides
  • dilation (int or iterable) – a parameter that controls the stride of elements in the window
  • return_indices (bool) – if True, will return the max indices along with the outputs. Useful for torch.nn.MaxUnpool2d later
  • ceil_mode (bool) – when True, will use ceil instead of floor to compute the output shape
_maxpool_same_padding(input_tensor)[source]

Performs the actual pooling for padding='same' and calculates the necessary padding

Parameters:input_tensor (torch.Tensor) – the input tensor to be pooled
Returns:pooled tensor
Return type:torch.Tensor
forward(input_tensor)[source]

Performs the actual pooling

Parameters:input_tensor (torch.Tensor) – the input tensor to be pooled
Returns:pooled tensor
Return type:torch.Tensor