keras icon indicating copy to clipboard operation
keras copied to clipboard

DepthwiseConv3D

Open SerdarHelli opened this issue 4 years ago • 2 comments

Hi,

There is still not DepthwiseConv3D in Keras. When are we going to be able to reach the DepthwiseConv3D?

SerdarHelli avatar May 26 '21 09:05 SerdarHelli

Hello Can I take up this issue if it is still un assigned?

nins15 avatar Sep 20 '22 08:09 nins15

Yeap :) I dont know how you gonna do . But it's okey

SerdarHelli avatar Sep 20 '22 08:09 SerdarHelli

@SerdarHelli, In Keras, you can do depthwise separable convolution (i.e. what a DepthwiseConv3D layer would do, if implemented), by using the Conv3D layer with groups=filters, where filters is the number of channels in your input tensor (which equals the number of channels in your output tensor, too). The only thing that's slightly annoying is that you need to know your number of input channels when you create the layer, rather than when the model is built.

To achieve SeparableConv3D, you then just have to put a pointwise convolution layer after this depthwise separable convolution, for example Conv3D with a kernel size of (1, 1, 1) (though it might be more performant to wrap a Conv2D layer with kernel size (1, 1) in a TimeDistributed layer; both approaches do exactly the same thing).

In pure tensorflow can do depthwise separable convolution with tf.nn.convolution. Just pass a kernel that has 1 for the input channel dimension size. This is what Conv3D with groups=filters does under the hood.

Also please take a look at this link for the reference. Thank you!

tilakrayal avatar Oct 13 '22 14:10 tilakrayal

@tilakrayal Thanks :D . But after one year, I got your response so I forgot my issue .

SerdarHelli avatar Oct 14 '22 16:10 SerdarHelli