facebookresearch / SparseConvNet

Submanifold sparse convolutional networks
https://github.com/facebookresearch/SparseConvNet
Other
2.04k stars 332 forks source link

Dilated convolution #239

Closed rdbs-oss closed 1 year ago

rdbs-oss commented 1 year ago

Hello,

thank you for open-sourcing and maintaining this repository.

I was wondering if there was a way (or a trick) enabling one to run dilated sparse convolutions.
I would like to train a sparse convolution layer with a huge receptive field, but I can not afford to have too many parameters, hence dilated convolution sounded adapted.

What I have tried so far is feeding a sparse tensor as SubManifoldConvolution's weight:

conv_layer = SubmanifoldConvolution()
conv_layer.weight = Parameter(conv_layer.weight.data.to_sparse())

-> Which fails at forward time: RuntimeError: sparse tensors do not have strides

I see a dirty way to proceed, which would be declaring a SubmanifoldConvolution with a big kernel, and zero-ing parts of the gradients at backward time through a hook, but it is computationally inefficient, since many gradients will be computed for nothing.

Thank you for your help,

btgraham commented 1 year ago

In the sparse setting, I don't think dilated convolutions make sense, as the overlap of a dilated kernel with the active locations is likely to be small. Instead, you should downsample using size=2 stride=2 convolutions, i.e. https://github.com/facebookresearch/SparseConvNet/blob/6919d707b6c1deb94964219c8943154b65517756/sparseconvnet/networkArchitectures.py#L132 or https://github.com/facebookresearch/SparseConvNet/blob/6919d707b6c1deb94964219c8943154b65517756/sparseconvnet/networkArchitectures.py#L203