﻿# GIN neighbor sums preserve multiplicity and separate the epsilon self term

Understand GIN multiset aggregation, why replacing sum with mean changes the operator, and how explicit self terms interact with preprocessing that adds graph self-loops.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-gin-neighbor-multiset-sum-self-epsilon/
Language: en

## Deduplicating messages can change the model input

A graph preprocessing job may remove repeated neighbor records because their feature vectors look identical. For a sum-based graph operator, equal messages from distinct neighbors still contribute with multiplicity. Removing one changes the aggregated input even though the set of distinct feature values remains unchanged.

The [GIN paper](https://arxiv.org/abs/1810.00826) studies the expressive power of neighborhood aggregation. Its multiset perspective matters when adapting the operator to application data rather than treating the neighborhood as an unordered set without counts.

## Sum and mean encode different distinctions

The [GINConv API](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GINConv.html) describes summing neighbor features before a neural transformation. Replacing that sum with a mean is a model change, not a numerically neutral normalization convenience.

A neighborhood containing repeated equal features can retain count information through a sum that a mean removes. This does not prove every trained sum-based network distinguishes every graph; learned transformations and available features still constrain the actual representation.

## The self contribution is explicit

The [implementation](https://raw.githubusercontent.com/pyg-team/pytorch_geometric/master/torch_geometric/nn/conv/gin_conv.py) adds the target node's features with a factor controlled by `eps`, and supports an optionally trainable value through `train_eps`. Preserve those settings with the trained weights.

If preprocessing also inserts self-loop edges, inspect whether the self message is now included through aggregation as well. A self-loop policy copied from another convolution can alter the intended self contribution without changing the layer's output shape.

## Permutation consistency needs joint relabeling

Reordering neighbors should preserve the mathematical sum, subject to numerical arithmetic effects. Reordering node rows, however, requires the same relabeling of edge endpoints and exported predictions. These are different transformations.

The [tensor-axis guide](/journal/tensor-axes-batch-sequence-hidden/) helps separate row placement from node identity. A permutation test must transform all related structures together; shuffling only feature rows tests a different graph assignment, not the intended invariance property.

## Test the operator before claiming graph discrimination

Use small neighborhoods with equal features but different multiplicities, then inspect self-loop settings and the saved epsilon state. Compare the complete configured layer rather than an untrained aggregation illustration alone.

The [artifact validation guide](/journal/safetensors-artifact-validation/) motivates retaining architecture configuration with parameters. Such tests verify implementation semantics. They do not establish universal graph-isomorphism solving, downstream classification accuracy, or causal meaning for a node representation.
