kdnet.pytorch icon indicating copy to clipboard operation
kdnet.pytorch copied to clipboard

the code in "kdnet.py" may be wrong

Open qiqihaer opened this issue 7 years ago • 3 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)"

qiqihaer avatar Dec 17 '18 02:12 qiqihaer

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

matherm avatar Feb 25 '19 15:02 matherm

@matherm I came into the same problem. Did you solve this problem?

fpshuang avatar Aug 28 '20 08:08 fpshuang

The solution can be found in (https://github.com/fxia22/kdnet.pytorch/issues/11#issuecomment-1174564811).

dhliubj avatar Jul 05 '22 03:07 dhliubj