MinkowskiEngine icon indicating copy to clipboard operation
MinkowskiEngine copied to clipboard

Miss point in MinkowskiConvolution

Open zb12138 opened this issue 11 months ago • 1 comments

dimension = 2
kernel_size = 3
stride= 3
out_channels = kernel_size**dimension
conv0_1 = ME.MinkowskiConvolution(
in_channels=1,
out_channels=out_channels,
kernel_size= kernel_size,
stride=stride,
bias=False,
dimension=dimension
)
conv0_1.kernel.data = torch.eye(kernel_size**dimension,out_channels).unsqueeze(1) 
coords =np.array([[0,0],[1,1],[5,5],[0,3]])
feat =np.array([[1],[10],[100],[1000]])
a,b=ME.utils.sparse_collate([coords],[feat]) 
A = ME.SparseTensor(features=b.float(), coordinates=a)
C = conv0_1(A)
map = A.coordinate_manager.kernel_map(A.coordinate_map_key,C.coordinate_map_key,kernel_size=kernel_size,stride=stride).items()
print(map)
print(C.F)

output:

dict_items([(8, tensor([[1],
        [2]], dtype=torch.int32)), (4, tensor([[3, 0],
        [0, 2]], dtype=torch.int32))]) # [kernelID, [[Aid],[Cid]] ]
tensor([[   0.,    0.,    0.,    0., 1000.,    0.,    0.,    0.,    0.],
        [   0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.], # miss 100
        [   0.,    0.,    0.,    0.,    1.,    0.,    0.,    0.,   10.]],
       grad_fn=<MinkowskiConvolutionFunctionBackward>) 

expect there is 100 (point 2, coord 5,5) in C.F and map

Image

zb12138 avatar Feb 28 '25 04:02 zb12138

The coords of C has [3,3] but not [6,6]. I think it is better to use round rather than floor to calculate the coords of output, so that it will has coord round([5,5]/3)*3 = [6,6]

zb12138 avatar Feb 28 '25 04:02 zb12138