---
kind: concept
slug: principal-neighbourhood-aggregation
title: Principal neighbourhood aggregation
summary: >-
  A message-passing layer that combines neighbour messages with four statistics (mean, standard deviation, max, min) and rescales each one by a degree term (identity, amplification, attenuation). One card so far: a two-level cell and tissue graph model, where the PNA layer beat GIN on 7-class breast tissue classification. Evidence is one dataset, three runs per model.
tags: [graph-neural-network, message-passing, aggregation, digital-pathology]
papers: ["2102.11057"]
related: [graph-neural-network]
status: draft
updated_at: 2026-11-15
---

## Overview

A graph layer updates each node from messages sent by its neighbours. How those
messages are combined, and how the result depends on how many neighbours a node
has, decides which structural information the layer keeps. Principal
neighbourhood aggregation (PNA) uses several statistics of the neighbour
messages at once, and several degree-based scalings of each statistic
[arxiv:2102.11057 eq. 5].

The four statistics are the mean, the standard deviation, the maximum and the
minimum of the neighbour messages. The three scalers are the identity (no
change), an amplification that grows with degree, and an attenuation that
shrinks it. The degree term is divided by δ, the average log-degree over the
training graphs [arxiv:2102.11057 eq. 5]. Each statistic and scaler pair gives one
block of the aggregate [arxiv:2102.11057 eq. 5].

The only paper card on wikillm that lists this concept is the one below. The
claims on this page rest on that paper's experiments.

## Variants

### Two-level PNA with an LSTM over layers (HACT-Net)

A stack of PNA layers runs on a cell-graph, whose nodes are nuclei. An LSTM
combines the outputs of all the layers [arxiv:2102.11057 eq. 6]. The per-cell embeddings are then summed for each tissue
region. Each tissue node concatenates that sum with its own features
[arxiv:2102.11057 eq. 7]. A second PNA stack, with its own LSTM over layers, runs
on the tissue-graph. Graph normalisation and batch normalisation follow each PNA
layer [arxiv:2102.11057 §IV.C.1]. The paper reports 61.53 ± 0.87 weighted F1 on
the 7-class BRACS task [arxiv:2102.11057 tab. V]. Card:
[Hierarchical Graph Representations in Digital Pathology](/papers/2102.11057).

## When to use which

| Situation | Use | Why |
|---|---|---|
| Nodes at two scales, with each fine node inside one coarse node | Two PNA stacks linked by an assignment matrix, as in HACT-Net | On BRACS, the hierarchical graph reached 61.53 ± 0.87, against 55.94 ± 1.01 for the cell-graph alone and 56.62 ± 1.35 for the tissue-graph alone [arxiv:2102.11057 tab. V] |
| Same graph, and you want a PNA layer in place of a GIN layer | PNA | In all four graph constructions the PNA variant scored higher. For HACT-Net the gap was 61.53 ± 0.87 against 59.73 ± 1.20 [arxiv:2102.11057 tab. III]. One dataset, three runs |
| No training-set degree statistics, or you cannot compute δ over the training graphs | Fix δ by hand, and say so in your results | The defined δ is the training average [arxiv:2102.11057 eq. 5]. The card's ablations do not vary δ, so a fixed value is untested in this paper |
| Graph building per image is costly | Consider a CNN over image patches | The HACT pipeline runs a nucleus detector, a CNN on every node patch and superpixel merging per region [arxiv:2102.11057 §IV.A] [arxiv:2102.11057 §IV.B]. Its multi-scale CNN baseline reached 52.83 ± 1.92 on the same task [arxiv:2102.11057 tab. V] |

Not covered by the card: small training sets, graphs with a single node type,
and tasks other than digital pathology. No result here addresses them.

## Implementation sketch

The sketch is the aggregation step only. The card does not give the update
function of the layer in full; check the paper before writing one.

```pseudocode
# One PNA aggregation at node v  [arxiv:2102.11057 eq. 5]
# Input:  messages m_1..m_d from the d neighbours of v, delta (training mean log-degree)
# Output: aggregate vector for v, one block per (statistic, scaler) pair

def pna_aggregate(messages, delta):
    # 1. Four statistics over the neighbour messages  [arxiv:2102.11057 §IV.C.1]
    stats = [mean(messages), std(messages), max(messages), min(messages)]
    # 2. Degree term from the node's degree d  [arxiv:2102.11057 eq. 5]
    log_d = log(d + 1)
    # 3. Scalers: identity, amplification, attenuation (as typeset in eq. 5)
    scalers = [1, log_d / delta, -log_d / delta]
    # 4. Every statistic times every scaler  [arxiv:2102.11057 eq. 5]
    return [s * c for s in stats for c in scalers]
```

Notes on the sketch:

- Step 3 follows the typeset form of eq. 5. Read literally, the attenuation
  term is the negative of the amplification term. See the pitfall below.
- The layer's update (how the aggregate is combined with the node's own state)
  sits outside this sketch [arxiv:2102.11057 §IV.C.1].

## Contradictions

No disagreement between papers, since only one card lists this concept.

Within the one card, the paper and the released code differ. The paper defines δ
as the training average, but the official config fixes it at 4. The card's
Paper vs code section lists this and the other differences: [wikillm card](/papers/2102.11057).

## Pitfalls

- **Scaler sign.** Eq. 5 is typeset as the logarithm of (D+1) raised to α,
  divided by δ. Taken literally, α = −1 gives −log(D+1)/δ, so the attenuation
  scaler is negative [arxiv:2102.11057 eq. 5]. The paper does not say whether
  its code uses this sign. The library that implements the layers is not in the
  paper's repository, so the card cannot settle it. Check it before you implement.
- **δ depends on the training set.** The paper defines δ over the training graphs
  [arxiv:2102.11057 eq. 5]. Compute it the same way, and do not use validation
  or test graphs.

## Papers

- [Hierarchical Graph Representations in Digital Pathology](/papers/2102.11057): introduces the two-level PNA model (HACT-Net) and compares PNA with GIN as the graph layer.
