theFoxofSky / ddfnet

The official implementation of the CVPR2021 paper: Decoupled Dynamic Filter Networks
MIT License
212 stars 34 forks source link

How can I get a dynamic depthwise convolution with ddf ? #30

Closed xiaoachen98 closed 2 years ago

xiaoachen98 commented 2 years ago

I want to make a 3x3 depthwise convolution dynamic, what should I change?

theFoxofSky commented 2 years ago

You can get a WeightNet-like depthwise filter by fixing all values in the spatial filter to 1 for 'mul' combination or 0 for 'add' combination.

spatial_filter = torch.ones(filter_size) output = ddf(input, channel_filter, spatial_filter, kernel_size, dilation, stride, 'mul')

or

spatial_filter = torch.zeros(filter_size) output = ddf(input, channel_filter, spatial_filter, kernel_size, dilation, stride, 'add')