I try to implement a depthwise separable convolution as described in the Xception paper for 3D input data (batch size, channels, x, y, z). Is the following class correct or am I missing something?
class DepthwiseSeparableConv(nn.Module): def __init__(self, in_channels, out_channels): super(DepthwiseSeparableConv, self).__init__() self.depthwise = nn.Conv3d(in_channels=in_channels, out_channels=in_channels, kernel_size=3, stride=1, padding=1, dilation=1, groups=in_channels, bias=False, padding_mode='zeros') self.pointwise = nn.Conv3d(in_channels=in_channels, out_channels=out_channels, kernel_size=1, stride=1, padding=0, dilation=1, groups=1, bias=False) self.bn = nn.BatchNorm3d(num_features=out_channels) def forward(self, x): out = self.depthwise(x) out = self.pointwise(out) return self.bn(out)
I think it might be necessary to additionally add a parameter for the number of kernels according to this example. But what would the number of kernels be then? I could not read something about this in the paper.