NVIDIA / MinkowskiEngine

Minkowski Engine is an auto-diff neural network library for high-dimensional sparse tensors
https://nvidia.github.io/MinkowskiEngine
Other
2.43k stars 360 forks source link

Minkownski Convolution with stride 2 and Kernel Size 4 #574

Open Mishalfatima opened 8 months ago

Mishalfatima commented 8 months ago

I used MinkownskiConvolution with a stride of 2 and kernel size 7. My input is a 2D image where every 3rd pixel is zeroed out. The input size is [224, 224] and sparsity looks something as follows:

1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 . . I was expecting the output to be:

4 0 0 6 0 0 0 0 0 0 0 0 6 0 0 9 .. ...

But the output is :

4 4 0 6 4 4 0 6 0 0 0 0 6 6 0 9 .. ... I am not sure what is happening here. In my understanding, if the kernel center is non-active element, no computation is performed, and zeros are fitted between elements/pixels. But here it seems that some of the elements (e.g. in first row of the returned matrix 4 4 0 6, second 4 is returned when 0 is centre in first row of original matrix i.e. [1 0 {0} 1] ). Kindly let me know what is going on here.


To Reproduce

a = torch.zeros((224,224)) a = torch.unsqueeze(a,0).unsqueeze(0).to(0) a[:, :,::3,::3] = 1

input = to_sparse(a) me_dwconv = MinkowskiConvolution( in_channels, out_channels, kernel_size=7, stride=2, bias=False, dimension=D ).to(0)

with torch.no_grad(): me_dwconv.kernel[:] = torch.ones((49)).unsqueeze(1).unsqueeze(2).to(0)

forward analytic test

output = me_dwconv(input)

out = output.dense()[0] print(out[0,0,0:4,0:4])


Expected behavior A clear and concise description of what you expected to happen.

4 0 0 6 0 0 0 0 0 0 0 0 6 0 0 9


==========MinkowskiEngine========== 0.5.4 MinkowskiEngine compiled with CUDA Support: True NVCC version MinkowskiEngine is compiled: 11050 CUDART version MinkowskiEngine is compiled: 11050


Additional context Add any other context about the problem here.