torchlayers.pooling module¶
-
class
torchlayers.pooling.
AvgPool
(kernel_size: int = 2, stride: int = None, padding: int = 0, ceil_mode: bool = False, count_include_pad: bool = True)[source]¶ Perform
avg
operation across firsttorch.Tensor
dimension.Depending on shape of passed
torch.Tensor
eithertorch.nn.AvgPool1D
,torch.nn.AvgPool2D
ortorch.nn.AvgPool3D
pooling will be used for3D
,4D
and5D
shape respectively (batch included).Default value for
kernel_size
(2
) was added.- Parameters
kernel_size (int, optional) – The size of the window. Default:
2
stride (int, optional) – The stride of the window. Default value is
kernel_size
padding (int, oprtional) – Implicit zero padding to be added on both sides. Default:
0
ceil_mode (bool, opriontal) – When True, will use
ceil
instead offloor
to compute the output shape. Default:True
count_include_pad (bool, optional) – When True, will include the zero-padding in the averaging. Default:
True
- Returns
Same shape as
input
with values pooled.- Return type
-
class
torchlayers.pooling.
GlobalAvgPool
[source]¶ Perform
mean
operation across firsttorch.Tensor
dimension.Usually used after last convolution layer to get mean of pixels from each channel.
Depending on shape of passed
torch.Tensor
either1D
,2D
or3D
pooling will be used for3D
,4D
and5D
shape respectively (batch included).- Returns
2D
tensor(batch, features)
- Return type
-
class
torchlayers.pooling.
GlobalMaxPool
[source]¶ Perform
max
operation across firsttorch.Tensor
dimension.Usually used after last convolution layer to get pixels of maximum value from each channel.
Depending on shape of passed
torch.Tensor
either1D
,2D
or3D
pooling will be used for3D
,4D
and5D
shape respectively (batch included).- Returns
2D
tensor(batch, features)
- Return type
-
class
torchlayers.pooling.
MaxPool
(kernel_size: int = 2, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False, ceil_mode: bool = False)[source]¶ Perform
max
operation across firsttorch.Tensor
dimension.Depending on shape of passed
torch.Tensor
eithertorch.nn.MaxPool1D
,torch.nn.MaxPool2D
ortorch.nn.MaxPool3D
pooling will be used for3D
,4D
and5D
shape respectively (batch included).Default value for
kernel_size
(2
) was added.- Parameters
kernel_size (int, optional) – The size of the window to take a max over. Default:
2
stride (int, optional) – The stride of the window. Default value is
kernel_size
padding (int, optional) – Implicit zero padding to be added on both sides. Default:
0
dilation (int) – Parameter controlling the stride of elements in the window. Default:
1
return_indices (bool, optional) – If
True
, will return the max indices along with the outputs. Useful fortorch.nn.MaxUnpool
later. Default:False
ceil_mode (bool, optional) – When True, will use
ceil
instead offloor
to compute the output shape. Default:False
- Returns
Same shape as
input
with values pooled.- Return type