Depthwise and Separable convolutions in Pytorch?

Anyone have an idea of how I can implement Depthwise convolutions and Separable Convoltuons in pytorch? The definitions of these can be found here.

Can one define those using just regular conv layers somehow?

1 Like

for Depthwise / Separable, you can use Conv’s groups parameter.

http://pytorch.org/docs/master/nn.html#conv2d

If groups = nInputPlane, then it is Depthwise. If groups = nInputPlane, kernel=(K, 1), (and before is a Conv2d layer with groups=1 and kernel=(1, K)), then it is separable.

24 Likes

Thanks so much, I will try it out.

Hi, Smith, is the Depthwise / Separable convolutions still very slow on Pytorch as before?

1 Like

Hi,

In Spatial Separable Convolution:
why is groups=nInputPlane?

Hi, hellodrx, I am facing this issue. Do you solve it ?

According to the definition, I think this implementation is not the separable conv.