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
avgoperation across firsttorch.Tensordimension.Depending on shape of passed
torch.Tensoreithertorch.nn.AvgPool1D,torch.nn.AvgPool2Dortorch.nn.AvgPool3Dpooling will be used for3D,4Dand5Dshape respectively (batch included).Default value for
kernel_size(2) was added.- Parameters
kernel_size (int, optional) – The size of the window. Default:
2stride (int, optional) – The stride of the window. Default value is
kernel_sizepadding (int, oprtional) – Implicit zero padding to be added on both sides. Default:
0ceil_mode (bool, opriontal) – When True, will use
ceilinstead offloorto compute the output shape. Default:Truecount_include_pad (bool, optional) – When True, will include the zero-padding in the averaging. Default:
True
- Returns
Same shape as
inputwith values pooled.- Return type
-
class
torchlayers.pooling.GlobalAvgPool[source]¶ Perform
meanoperation across firsttorch.Tensordimension.Usually used after last convolution layer to get mean of pixels from each channel.
Depending on shape of passed
torch.Tensoreither1D,2Dor3Dpooling will be used for3D,4Dand5Dshape respectively (batch included).- Returns
2Dtensor(batch, features)- Return type
-
class
torchlayers.pooling.GlobalMaxPool[source]¶ Perform
maxoperation across firsttorch.Tensordimension.Usually used after last convolution layer to get pixels of maximum value from each channel.
Depending on shape of passed
torch.Tensoreither1D,2Dor3Dpooling will be used for3D,4Dand5Dshape respectively (batch included).- Returns
2Dtensor(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
maxoperation across firsttorch.Tensordimension.Depending on shape of passed
torch.Tensoreithertorch.nn.MaxPool1D,torch.nn.MaxPool2Dortorch.nn.MaxPool3Dpooling will be used for3D,4Dand5Dshape 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:
2stride (int, optional) – The stride of the window. Default value is
kernel_sizepadding (int, optional) – Implicit zero padding to be added on both sides. Default:
0dilation (int) – Parameter controlling the stride of elements in the window. Default:
1return_indices (bool, optional) – If
True, will return the max indices along with the outputs. Useful fortorch.nn.MaxUnpoollater. Default:Falseceil_mode (bool, optional) – When True, will use
ceilinstead offloorto compute the output shape. Default:False
- Returns
Same shape as
inputwith values pooled.- Return type