Pytorch implementation of Depthwise Convolution

tf.keras.layers.DepthwiseConv2D(
    kernel_size,
    strides=(1, 1),
    padding="valid",
    depth_multiplier=1,
    data_format=None,
    dilation_rate=(1, 1),
    activation=None,
    use_bias=True,
    depthwise_initializer="glorot_uniform",
    bias_initializer="zeros",
    depthwise_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    depthwise_constraint=None,
    bias_constraint=None,
    **kwargs
)

What is the Pytorch’s implementation of the above Keras equivalent of Depthwise Convolution?

1 Like

Hi Rituraj,

The depthwise convolutions are implemented in pytorch in the Conv modules with the group parameter.
For an input of c channels, and depth multiplier of d, the nn.Conv2d parameters become
in_channels = c
out_channels = d*c
groups = c