Skip to content

Commit

Permalink
fixed point conv, wrong adjacency size bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s committed Apr 2, 2019
1 parent 8680766 commit e4589ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
12 changes: 8 additions & 4 deletions examples/pointnet++.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ def forward(self, data):
pos, batch = data.pos, data.batch

idx = fps(pos, batch, ratio=0.5) # 512 points
edge_index = radius(pos[idx], pos, 0.1, batch[idx], batch, 64)
x = F.relu(self.local_sa1(None, pos, edge_index))
edge_index = radius(
pos[idx], pos, 0.1, batch[idx], batch, max_num_neighbors=64)
N, M = pos.size(0), idx.size(0)
x = F.relu(self.local_sa1(None, pos, edge_index, size=(N, M)))
pos, batch = pos[idx], batch[idx]

idx = fps(pos, batch, ratio=0.25) # 128 points
edge_index = radius(pos[idx], pos, 0.2, batch[idx], batch, 64)
x = F.relu(self.local_sa2(x, pos, edge_index))
edge_index = radius(
pos[idx], pos, 0.2, batch[idx], batch, max_num_neighbors=64)
N, M = pos.size(0), idx.size(0)
x = F.relu(self.local_sa2(x, pos, edge_index, size=(N, M)))
pos, batch = pos[idx], batch[idx]

x = self.global_sa(torch.cat([x, pos], dim=1))
Expand Down
9 changes: 6 additions & 3 deletions torch_geometric/nn/conv/point_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ def reset_parameters(self):
reset(self.local_nn)
reset(self.global_nn)

def forward(self, x, pos, edge_index):
def forward(self, x, pos, edge_index, size=None):
""""""
N, M = edge_index[0].max().item() + 1, edge_index[1].max().item() + 1
return self.propagate(edge_index, size=(N, M), x=x, pos=pos)
if size is None:
N = edge_index[0].max().item() + 1
M = edge_index[1].max().item() + 1
size = (N, M)
return self.propagate(edge_index, size=size, x=x, pos=pos)

def message(self, x_j, pos_j, pos_i):
msg = pos_j - pos_i
Expand Down

0 comments on commit e4589ba

Please sign in to comment.