Conv2dWithSamePadding

class Conv2dWithSamePadding(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

A Convolution 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.conv.Conv2d

Parameters:
  • in_channels (int) – channels of convolution input
  • out_channels (int) – number of filters and output channes
  • kernel_size (int or Iterable) – specifies the kernel dimensions. If int: same kernel size is used for all dimensions
  • stride (int or Iterable, optional) – specifies the convolution strides (default: 1) If int: same stride is used for all dimensions
  • padding (int or Iterable or str, optional) –

    specifies the input padding (default: 0) If int: same padding is used for all dimensions If str: only supported string is ‘same’, which calculates the

    necessary padding during forward
  • dilation (int or Iterable, optional) – specifies the convolution dilation (default: 1) If int: same dilation is used for all dimensions
  • groups (int, optional) – number of convolution groups (default: 1)
  • bias (bool, optional) – whether to include a bias or not (default: True)
_convolution_same_padding(input_tensor)[source]

Convolves the input and calculates the necessary padding

Parameters:input_tensor – the input tensor to be convolved
Returns:tensor after convolution
Return type:class: torch.Tensor
forward(input_tensor: <sphinx.ext.autodoc.importer._MockObject object at 0x7fd68abe0c88>)[source]

Convolves the input

Parameters:input_tensor – the input tensor to be convolved
Returns:tensor after convolution
Return type:class: torch.Tensor