Depthwise Separable Convolution in UNet


I apply DSC in my UNet architecture, like in this paper about SD-UNet.
While it works well during encoding, the decoding process throws the following error

out_channels must be divisible by groups

This occurs since in DSC (as far as I know) the number of groups is equal to the number of input channels. However, the latter is inherently larger than the output channels during the upsampling process.

I attach the code snippet of the unet model and parts. What should be done to overcome this situation?

As the error message claims apparently the number of out_channels is not divisible by groups.
Looking at the code I guess that the first conv layer in DoubleConv might create the issue, if mid_channels is not divisible by in_channels. Could you check it and adapt the number of channels accordingly?