octree-nn / ocnn-pytorch

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

Calculating the features at different depths #22

Closed raoshashank closed 1 year ago

raoshashank commented 1 year ago

@wang-ps I have a point cloud with N points and 3 channel features. Creating an octree of depth 4 with this point cloud creates an octree with features only at depth 4. How do I compute the features at a non-empty node in depth 3,2 and 1, for example, by setting the features at the parent node as the average of the feature values of the child nodes (without using a OctreeConvBnRelu block as a downsampler)?

The OCNN paper says that pooling is equivalent to downsampling the features to lower depths, so I tried just average pooling the features at depth 4 with a kernel 222 and stride 2, but the output doesn't have the same size as the number of nodes in depth 3... E.g. I want to convolve the features at all layers of an octree separately, but the convolution cannot be run after the pooling since the number of nodes generated by pooling at depth d is not the same as nnum[d-1]:

self.pool = ocnn.nn.OctreeAvgPool(kernel_size=[2,2,2],stride=2,nempty=False)
convs = dict()
depth, full_depth = self.depth, self.full_depth
data = dict()
data[depth] = self.get_input_feature(octree,'ND')
for i,d in enumerate(range(depth, full_depth-1, -1)):
    convs[d] = self.encoder_blks[i](data[d],octree,d)
    if d>full_depth:
      data[d-1] = self.pool(data[d],octree,d)

where, the encoder blocks are OctreeResBlocks with fixed input size (channel size) and different output sizes. Thanks in advance!

wang-ps commented 1 year ago

just average pooling the features at depth 4 with a kernel 222 and stride 2, but the output doesn't have the same size as the number of nodes in depth 3

The node number should be the same as node number in depth 3. You can inspect the ocnn.models.LeNet as an example.