[Feature Proposal] Topology-Constrained Linear Layer (Watts–Strogatz / Barabási–Albert weight masks) #10671
narwanRanak
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'd like to contribute a new module —
TopologyMaskedLinear— that constrains the active weight positions of a dense linear layer to follow a graph-theoretic topology (Watts–Strogatz small-world or Barabási–Albert scale-free). This fills a gap in PyG'snn.densemodule: while PyG has powerful GNN convolution layers that operate on externally provided graphs, there is currently no primitive for constraining the internal weight connectivity of a linear layer using graph topology.Contributors: Ranak (ranak23426@iiitd.ac.in) — Primary · Kartikeya (kartikeya22241@iiitd.ac.in) — Secondary
Motivation
Research in network science has shown that neural network weight matrices, when thresholded, naturally develop small-world and scale-free properties during training (e.g., Watts & Strogatz 1998, Barabási & Albert 1999). A natural question is: what happens if we impose these topologies as structural inductive biases at initialisation?
We have been running experiments on CIFAR-10/100 using WS and BA graph masks on MLP weight matrices, tracking how the topology evolves during training and whether the small-world structure is preserved. The main challenges are:
nn.Modulerequires boilerplate every time.A reusable PyG module would make this class of experiment much cleaner to express.
Proposed API
Graph mask generators (in
torch_geometric.utils)These are pure-PyTorch bipartite adaptations of the classical WS and BA models — no NetworkX dependency.
TopologyMaskedLinear(intorch_geometric.nn.dense)A drop-in replacement for
torch_geometric.nn.dense.Linearwith a fixed topology mask:The mask is registered as a non-trainable buffer. Forward:
F.linear(x, weight * mask, bias).WSEdgeRegLoss(intorch_geometric.nn.dense)An optional regularisation loss that prevents gradient descent from eroding the WS ring structure:
Implementation plan
We have a working implementation ready. Proposed file locations:
Happy to open a PR once there's a green light on the API design.
Prior work / references
Questions for the team
torch_geometric.nn.densethe right home, or would you prefertorch_geometric.nn.sparseor a new submodule?torch_geometric.utilsor closer totorch_geometric.nn?WSEdgeRegLoss, or should I keep that in a follow-up PR?Happy to adjust scope based on feedback. Thanks for considering this!
Beta Was this translation helpful? Give feedback.
All reactions