Original Paper
Dynamic Graph CNN for Learning on Point Clouds
Wang et al. (2018). ACM TOG 2019
Read paper →What EdgeConv does
EdgeConv operates in three steps per layer:
- Build k-NN graph: Find k nearest neighbors for each point in the current feature space
- Compute edge features: For each edge (i, j), create [h_i, h_j - h_i] (absolute + relative)
- Apply MLP + max pool: Process edge features with MLP, then max-pool over neighbors
PyG implementation
import torch
import torch.nn.functional as F
from torch_geometric.nn import EdgeConv, global_max_pool
from torch_geometric.nn import knn_graph
class DGCNN(torch.nn.Module):
def __init__(self, out_channels, k=20):
super().__init__()
self.k = k
self.conv1 = EdgeConv(
torch.nn.Sequential(
torch.nn.Linear(2 * 3, 64), # 2x input dim (concat)
torch.nn.ReLU(),
torch.nn.Linear(64, 64),
), aggr='max'
)
self.conv2 = EdgeConv(
torch.nn.Sequential(
torch.nn.Linear(2 * 64, 128),
torch.nn.ReLU(),
torch.nn.Linear(128, 128),
), aggr='max'
)
self.classifier = torch.nn.Linear(128, out_channels)
def forward(self, x, batch):
# Dynamic graph: recompute k-NN each layer
edge_index = knn_graph(x, self.k, batch=batch)
x = self.conv1(x, edge_index)
edge_index = knn_graph(x, self.k, batch=batch)
x = self.conv2(x, edge_index)
x = global_max_pool(x, batch)
return self.classifier(x)
# Point cloud: N points x 3 coordinates
model = DGCNN(out_channels=40, k=20) # ModelNet40knn_graph is called before each EdgeConv to rebuild the graph from current features. At layer 1, neighbors are spatially close. At deeper layers, they are semantically similar.
When to use EdgeConv
- Point cloud classification. ModelNet40, ScanNet. EdgeConv is the standard baseline for 3D shape recognition.
- Point cloud segmentation. ShapeNet part segmentation. Local geometric patterns captured by dynamic k-NN are essential for part boundaries.
- Data without fixed graph structure. Any unstructured point set (LiDAR scans, particle physics events) where you need to discover the graph from data.
When not to use EdgeConv
- Fixed-structure graphs. If your graph structure is given and meaningful (social networks, knowledge graphs), recomputing it each layer discards useful information. Use standard GNN layers.
- Large graphs. k-NN computation is expensive for large point counts. For 100K+ points, use voxelization or radius-based neighbors.