the code in "kdnet.py" may be wrong
qiqihaer opened this issue · comments
In my opinion, the index selection part in the "KDNet_Batch" in "kdnet.py" may be wrong. The offset addition part of variable "sel" makes that the order in "sel" can not match the real points' order in "x".
The mistake can be fixed by change
"sel = Variable(sel + (torch.arange(0,dim) * 3).repeat(batchsize,1).long()).view(-1,1)"
into
"sel = Variable(sel * dim + torch.arange(0,dim).repeat(batchsize,1).long()).view(-1,1)"
How does this fix the failure? When I run the code, it crashes at the mentioned line with:
inconsistent tensor size, expected r_ [2], t [2] and src [2048] to have the same number of elements, but got 2, 2 and 2048 elements respectively at)
This happens in both train.py (line 38) and test.py (line 36).
I cannot even see how this line can ever run? I mean sel
in
sel = Variable(sel + (torch.arange(0, dim) * 3).long())
is of shape (2,) in case c[-1]
and (torch.arange(0, dim)
is of shape (2048,).
Is the addition really correct here? Or is c maybe in reverse order and we should write c[0..11] instead of c[-1..-11] which makes more sense to me and removes the error. But I'm not sure if this is mathematically correct.
Best wishes,
Matthias
The solution can be found in (#11 (comment)).