All models

MemPooling

Graph pooling layer whose learned memory keys act as cluster centroids, coarsening nodes by soft assignment.

Graphs and geometry · 20 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (23 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
8.3K
Operations
20
Framework
PyTorch
Recurrent
No
Published
ICLR 2020
Cited by
52 (as of 18 October 2026)
Authors
Amir Hosein Khasahmadi, Kaveh Hassani, Parsa Moradi and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m1751
Graph hash
422e8c81d48b2befd0261887081ece200b11629abb89fd1e1d51a86a1a109cfa
Skeleton hash
1eb5de36fdc669f40e08abaf7b0a0398ce776ffe26a0e44a42fc130628312cd6
Architecture hash
ade450c1d4822396a1a344b9c2cca7932527e37b747d589bea3aeedac382ee4b
Diagram SHA-256
b55fdacb11abb20d682c90dfa3a10beacf44597ff233f9c2ee8ff7cbf7a6d732
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

torch_geometric.nn.pool.MemPooling(in_channels=64, out_channels=80, heads=5, num_clusters=10, tau=1.0)

What it is

MemPooling is a memory-based pooling layer for graph neural networks that learns a coarsened graph representation based on soft cluster assignments. The paper introduces it as an efficient memory layer for GNNs that can jointly learn node representations and coarsen the graph. The idea is to treat the incoming node representations as queries and a learned array of memory keys as the cluster centroids of those queries.

Similarity between a query and a key is measured with the Student's t-distribution as a kernel, a deliberately clustering-friendly choice. The keys form a multi-head array, and a 1x1 convolution aggregates the per-head assignment matrices into a single soft assignment matrix. A memory read then multiplies that assignment matrix against the original queries to produce the coarsened node representations. A single-layer feed-forward network projects the coarsened embeddings into the next layer's space. Because the layer does not explicitly require connectivity information, it relies on global information rather than local topology and so does not struggle with the oversmoothing problem.

The paper builds two networks on this layer, memory-based GNN (MemGNN) and graph memory network (GMN), that can learn hierarchical graph representations. GMN learns the hierarchical representations purely from memory layers and hence does not require message passing at all. Across nine graph classification and regression benchmarks, the proposed models reached state-of-the-art results on eight. Training mixes a supervised loss with an unsupervised clustering loss, a Kullback-Leibler divergence between the soft assignments and an auxiliary target distribution. PyTorch Geometric exposes that term as an additional KL divergence-based loss on the layer.

On molecules, the learned clusters line up with chemical substructures such as a carbon chain and a Hydroxyl group. Warm-starting the keys with K-Means brought no significant improvement over randomly selected keys.

Key idea. An efficient memory layer for GNNs that can jointly learn node representations and coarsen the graph. Its keys act as the cluster centroids of the queries, and a 1x1 convolution aggregates the multi-head soft assignments into a single matrix.

  • MemPooling
  • memory pooling
  • memory layer
  • Memory-Based Graph Networks
  • MemGNN
  • GMN
  • graph memory network
  • graph pooling
  • graph coarsening
  • soft cluster assignment
  • hierarchical graph representation
  • graph classification
  • PyTorch Geometric
  • torch_geometric

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{khasahmadi2020memorybasedgraphnetworks,
      title={Memory-Based Graph Networks}, 
      author={Amir Hosein Khasahmadi and Kaveh Hassani and Parsa Moradi and Leo Lee and Quaid Morris},
      year={2020},
      eprint={2002.09518},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2002.09518}, 
}