fxia22 / kdnet.pytorch

implementation "Escape from Cells: Deep Kd-Networks for The Recognition of 3D Point Cloud Models" in pytorch

Home Page:https://arxiv.org/abs/1704.01222

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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

The solution can be found in (#11 (comment)).