Skip to content

Commit e4589ba

Browse files
committed
fixed point conv, wrong adjacency size bug
1 parent 8680766 commit e4589ba

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

examples/pointnet++.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ def forward(self, data):
3737
pos, batch = data.pos, data.batch
3838

3939
idx = fps(pos, batch, ratio=0.5) # 512 points
40-
edge_index = radius(pos[idx], pos, 0.1, batch[idx], batch, 64)
41-
x = F.relu(self.local_sa1(None, pos, edge_index))
40+
edge_index = radius(
41+
pos[idx], pos, 0.1, batch[idx], batch, max_num_neighbors=64)
42+
N, M = pos.size(0), idx.size(0)
43+
x = F.relu(self.local_sa1(None, pos, edge_index, size=(N, M)))
4244
pos, batch = pos[idx], batch[idx]
4345

4446
idx = fps(pos, batch, ratio=0.25) # 128 points
45-
edge_index = radius(pos[idx], pos, 0.2, batch[idx], batch, 64)
46-
x = F.relu(self.local_sa2(x, pos, edge_index))
47+
edge_index = radius(
48+
pos[idx], pos, 0.2, batch[idx], batch, max_num_neighbors=64)
49+
N, M = pos.size(0), idx.size(0)
50+
x = F.relu(self.local_sa2(x, pos, edge_index, size=(N, M)))
4751
pos, batch = pos[idx], batch[idx]
4852

4953
x = self.global_sa(torch.cat([x, pos], dim=1))

torch_geometric/nn/conv/point_conv.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ def reset_parameters(self):
4040
reset(self.local_nn)
4141
reset(self.global_nn)
4242

43-
def forward(self, x, pos, edge_index):
43+
def forward(self, x, pos, edge_index, size=None):
4444
""""""
45-
N, M = edge_index[0].max().item() + 1, edge_index[1].max().item() + 1
46-
return self.propagate(edge_index, size=(N, M), x=x, pos=pos)
45+
if size is None:
46+
N = edge_index[0].max().item() + 1
47+
M = edge_index[1].max().item() + 1
48+
size = (N, M)
49+
return self.propagate(edge_index, size=size, x=x, pos=pos)
4750

4851
def message(self, x_j, pos_j, pos_i):
4952
msg = pos_j - pos_i

0 commit comments

Comments
 (0)