octree-nn / ocnn-pytorch

Octree-based 3D Convolutional Neural Networks
MIT License
156 stars 17 forks source link

What is the purpose of the nempty parameter in ResNet and LeNet? #6

Closed harryseely closed 1 year ago

harryseely commented 1 year ago

This is a great implementation and I appreciate how easy you have made it to set up!

I currently have the nempty LeNet model parameter set to True. If I set nempty to False I get the following error.

model = LeNet(in_channels=3, out_channels=4, stages=3, nempty=False)

AssertionError: The shape of input data is wrong.

I have two questions: 1) What is the purpose of the nempty parameter? 2) Why is the input shape wrong when I enable nempty?

Thanks!

wang-ps commented 1 year ago

Thanks for your encouragement!

What is the purpose of the nempty parameter?

Each octree node has exactly 8 children nodes, among which some children nodes are non-empty and some are empty. If nempty is true, the convolution is performed on non-empty octree nodes only, which is exactly the same as SparseConvNet and MinkowsiNet; and if nempty is false, the convolution is performed on all octree nodes, which is essential for shape reconstruction tasks and can also be used in classification and segmentation (with slightly better performance and larger memory cost).

Why is the input shape wrong when I enable nempty?

You should set the nempty parameter globally via:

python classification.py --config configs/cls_m40.yaml SOLVER.alias time  MODEL.nempty True

The reason for the error is that you only modify the input nempty for the class LeNet, but this parameter also affects the following line of code https://github.com/octree-nn/ocnn-pytorch/blob/1f0dcb496500801311149d6537a53670b7b48b0b/projects/classification.py#L37

harryseely commented 1 year ago

Ok that makes sense and explains the issue. Thanks!

raoshashank commented 1 year ago

@wang-ps I see that for the completion network (OUNet), the upsampling step has nempty=False and this results in the data getting de-padded before deconvolution, so that before deconvolution, the data is only associated with the non-empty nodes of the output-octree. Isn't this the opposite of the behavior expected with nempty=False? Thanks!