GraphMAE.
Learning from missing information.
All five chapters, worked answers and static comparison states. This edition loads zero scripts.
01
A graph gives context
A missing row is still attached to its neighbors. That is the opportunity—and the constraint.
Start with six rows
Imagine six sites connected by a small network. You know two feature values at each site, but deliberately cover the row at B. What could a model use to reconstruct it? Nearby sites offer one source of context. The connections say which sites are nearby in the graph.
We use a power-grid-shaped synthetic graph. Its two feature channels, and , are dimensionless invented numbers. They are not voltages, power injections, sensor readings, or simulated grid states. The shape supplies a memorable example; it supplies no evidence about electrical behavior.
Original feature rows (u, v)
- A
- (2, 1)
- B
- (1, 2)
- C
- (2, 2)
- D
- (3, 1)
- E
- (1, 3)
- F
- (2, 3)
B connects to A, C and D. Links are undirected; position and line length carry no physical units.
A feature vector is an ordered list. At B it is ; swapping the entries changes its meaning. Stack the six vectors as rows to get . The graph adds a node set and an edge set . An edge joins two rows; it is not another feature value.
CL-012 · All six feature rows and graph connections are teaching assumptions.
One message-passing step
B has three neighbors: A, C and D. A message-passing layer collects their vectors, combines them, and transforms the result using shared learned weights. “Shared” means the same rule is applied at different nodes; it does not mean every node receives the same result.
Let be the neighbors of , its starting vector, and learned matrices. One illustrative layer is:
The sum collects neighbors, division makes a mean, and is a nonlinear transformation. With two input features and output features, both matrices have shape , treating each vector as a column in this equation.
Before the transformation, B's original neighbor mean is . That is not the target . Graph context offers information to learn from; adjacency alone does not specify a perfect reconstruction rule.
This mean layer is a refresher, not a reproduction of GraphMAE's architecture. Graph attention can instead learn neighbor-dependent weights. The authors' main GraphMAE recipe uses graph attention, while studying other architecture choices.
Targets without manual labels
A training objective compares a prediction with a target. Self-supervision changes where that target comes from: here, the original feature row supplies it. We hide a row from the predictor while retaining its original values to score the prediction.
GraphMAE, introduced by Hou and colleagues in 2022, centers its original objective on masked node-feature reconstruction. Its graph supplies context, and its encoder learns a representation through this pretext task. This is a particular graph method, not a new name for every masked autoencoder.
CL-001 · GraphMAE, original paper, §3
The next question is more precise than “what is masked?” We need to follow the original row, the input token, and the hidden representation separately.
02
Hide a row. Keep its target.
Follow the original GraphMAE computation, including the second mask before the decoder.
One row, two paths
Let be the selected nodes. In the clean example, . The encoder receives a corrupted matrix , where B's row is replaced by a learned input mask token . The scoring path retains the original .
The token is a trainable vector, not the target and not a command to delete B. In the reviewed author code it starts at zero, then can be updated during learning. B remains a node with its edges.
WITHHELD TARGET PATH: original B = (1, 2) → final comparison only
- 1OriginalB: (1, 2)
Keep an untouched target on the scoring path.
- 2Corrupt featuresB: [MASK]
Learned input token replaces the selected row; graph retained.
- 3Graph encoderB: hB
Trainable encoder mixes available graph context.
- 4Project, then re-maskB: 0
Bias-free projection; zero the SAME selected rows for the graph decoder.
- 5Graph decoderB: predicted row
Aggregate representations and reconstruct two features per node.
- 6Select and scoreB only enters loss
Compare reconstructed B with its untouched target (1, 2).
Architecture trace, not an executed neural forward pass. Only selected feature rows are targets. In the reviewed core code the graph decoder is one layer and returns the original feature width. CL-003–005.
CL-003 · Author implementation, encoding_mask_noise and enc_mask_token
Why mask again?
The encoder computes . Each row is now a learned representation rather than a raw feature vector. A learned, bias-free projection maps the encoder output into the decoder's input space. In the graph-decoder path, the implementation overwrites the projected rows at the same nodes in M with zero.
Call that re-masked matrix . The graph decoder predicts , producing a feature row for each node. At B, it has a zero input row and can aggregate neighboring representations. This removes the direct route from B's own encoder row into B's decoder input.
That routing choice does not prove all information about B has vanished elsewhere. Message passing mixes information across connected nodes. Re-masking specifies which local decoder input is removed; it is not an information-theoretic guarantee against shortcuts.
CL-004 · MLP/linear alternatives do not follow this re-masking branch. This guide teaches the graph decoder path.
CL-004 · Author implementation, projection, re-mask and decoder, lines 246–260
The decoder emits more than the loss scores
All six reconstructed rows may exist, but this objective scores only the selected rows. With , an error at A does not enter this step's loss. With , the objective averages B's and D's terms. “Masked-only” describes which rows are scored, not which intermediate activations or weights can receive gradients.
The encoder, input token, projection and decoder participate in learning. Our interactive lab will do none of those updates: it evaluates the same loss selection on explicitly prescribed reconstructions.
CL-005 · Author implementation, recon[mask_nodes] and x[mask_nodes]
What differs from the all-token example?
The implementation can replace some selected rows with features sampled from other nodes instead of the token. Its command-line replacement default is zero, while constructor defaults and dataset configurations differ. Our walkthrough uses replacement zero and no edge dropout. These are not universal GraphMAE hyperparameters.
An optional encoder edge-dropout branch also exists; the decoder receives the pre-drop graph. Record settings explicitly in a real experiment, and check integer rounding before adapting large-graph corruption settings to six nodes.
CL-014 · Command-line defaults
03
What survives the mask?
Mask placement changes available context. A fixed reconstruction table does not measure how hard a model would find it.
Hide one row. Then hide its neighbors.
First hide B. A, C and D still have their original rows. Now hide B, C and D together. B remains connected to all three neighbors, but only A still provides its original row directly. C and D provide mask-token inputs at the encoder's first layer.
B hidden
Visible original neighbors of B: A, C, D.
B, C, D hidden
Visible original neighbors of B: A.
Dashed circles mark hidden feature rows. C and D still exist and can relay latent messages; this count describes first-layer original inputs only. CL-012, CL-018.
The distinction is between a neighbor existing and that neighbor's original features being visible. With multiple message-passing layers, context can travel farther: C connects to F, and D to E. Repeated aggregation expands the paths through which information can influence B. It does not make missing features recoverable by definition.
CL-012 · The comparison counts visible original feature rows. It is not a measured masking-difficulty curve.
A mask ratio leaves out its location
Our masks select one, two, or three of six nodes: approximately 16.7%, 33.3%, and 50%. These are teaching states, not a recommended schedule. Two masks of the same size can preserve different neighborhoods and different signals.
Holding a prediction fixed while changing the scored mask asks: which errors are averaged? Retraining under different masking policies asks: what representations does that learning process produce? The second needs controlled runs, a downstream task, and uncertainty estimates. The first can be answered exactly in a browser.
Define the prediction-time information boundary before pretraining. If an evaluation claims new-graph generalization, using that test graph during pretraining changes the claim, even without labels. A same-graph transductive protocol can be valid; it needs to be named.
CL-010 · Author inductive entry point; evaluation advice here is a qualified inference
Using edges is not reconstructing edges
Our edges determine message-passing neighborhoods. The target remains a feature row such as . We do not predict whether AB or BC exists. Edge reconstruction needs its own target, output, and objective.
The original GraphMAE paper and reviewed core graphmae/models/edcoder.py path focus on features. There is an optional edge-masking loss branch in the repository's separate chemistry pretraining script. That detail is a reason to name the exact path and configuration, rather than infer behavior from a project name.
CL-001 · GraphMAE, original objective
CL-016 · Separate chemistry script, optional mask_edge branch
We now have the target and scoring set. The remaining choice is what it means for a reconstructed row to match.
04
Direction is a choice
Scaled cosine error rewards aligned features. Squared error also sees their magnitude.
One row, by hand
Take B's target, , and prescribe . This is a chosen vector, not a trained decoder's output. Their dot product is . Each vector's Euclidean norm, or length, is .
Cosine similarity measures alignment. For nonzero vectors it lies between −1 and 1: opposite directions at −1, a right angle at 0, the same direction at 1. Here . The angular residual is 0.2.
GraphMAE's scaled cosine error raises the residual to an exponent , then averages over selected nodes:
With only B selected and , the score is . The exponent acts before the mean. “Scaled” here refers to this power, not an extra fitted multiplier.
CL-006 · Author SCE implementation: normalize, dot, residual power, mean
Inspect the objective
Predict before changing the controls: if you double the prescribed prediction from to , does SCE change? Does squared error change? Start with one variable; the mask and exponent can stay fixed.
Which errors count?
Synthetic features. Prescribed reconstructions. No encoder, decoder, or weights are trained here. Changing the mask changes input visibility and scored rows; it does not train new predictions.
SELECTED-NODE MEANS
Dashed node = hidden input row. Edges remain. All values are dimensionless; MSE first averages the two feature errors.
Masked B · scale 1 · gamma 2. SCE 0.04; MSE 1. Mean over 1 selected node only.
B · scored
- Encoder input
- [MASK]
- Withheld target
- (1, 2)
- Prescribed prediction
- (2, 1)
- Cosine / residual
- 0.8 / 0.2
- SCE term / MSE term
- 0.04 / 1
- Visible input neighbors
- A, C, D
Unscored nodes: A, C, D, E, F. They may supply context, but have no direct term in this mean.
| Case / selected | SCE | MSE |
|---|---|---|
| BaselineB · scale 1 | 0.04 | 1 |
| Doubled predictionB · scale 2 | 0.04 | 4.5 |
| Two selectedB, D · scale 1 | 0.020051 | 0.75 |
| Three selectedB, C, D · scale 1 | 0.013367 | 0.5 |
Values rounded to six decimals; computation uses full precision. Scale changes prescribed prediction magnitude only. The complete reading edition retains these comparisons.
For comparison, this lab uses per-feature mean squared error, then averages over selected nodes. The feature dimension is :
At B the baseline is . Doubling gives . SCE remains 0.04: positive rescaling cancels between the cosine numerator and denominator.
Now select B, C and D. The average can fall even though more features are withheld. C's prescribed direction is exactly right and D's nearly right; their small terms lower the mean. The predictions were not learned under the new mask. A lower number here does not imply easier training or a better representation.
CL-013 · Deterministic derivations from CL-012's prescribed vectors. Browser, static table and runnable lab share one numerical module.
What the exponent changes
Increasing from 1 to 2 changes B's term from 0.2 to 0.04. For a residual between zero and one, higher powers make its numerical contribution smaller. Larger residuals become more prominent relative to smaller ones.
That is not a promise that every individual loss decreases. If , then : squaring raises the term from 1.5 to 2.25. Changing the loss scale changes optimization behavior; a smaller displayed value does not itself mean better training.
Boundary: what if a feature vector is zero?
The mathematical cosine divides by both vector lengths and is undefined for a zero vector. Our teaching functions reject that case. The author's code uses PyTorch's epsilon-protected F.normalize, so zero inputs have a defined numerical path: a zero normalized row gives dot product zero and residual one. Extremely small vectors also depend on epsilon. These are different domain policies; the lab is not a bit-for-bit PyTorch replacement.
A perfect angle is not a perfect row
There is a stronger counterexample: let . The direction is exact, so SCE is zero for every positive exponent. Yet the values are wrong. Per-feature squared error is .
This is a property of the objective, not a defect discovered in a trained model. If absolute magnitude matters downstream, this distinction belongs in your experimental design. Evaluate magnitude recovery directly or compare a suitable magnitude-sensitive objective. Whether doing so improves performance remains an empirical question.
05
Beyond this graph
A reusable encoder is a starting point. Transfer is an evaluation claim.
What leaves pretraining?
After pretraining, extract representations with the encoder. The reviewed implementation's embed(g,x) calls the encoder on the supplied graph and features, without the corruption-and-decoder path. A linear probe freezes these representations and trains a small linear predictor. Fine-tuning updates some or all encoder weights for the downstream target.
A probe asks what the representation already makes accessible to a simple predictor. Fine-tuning also asks how it adapts with supervision. Neither question is answered by our lab's reconstruction score.
CL-008 · Author inductive linear evaluation and pretraining entry point
Can it handle a different topology?
A message-passing encoder applies shared local rules, so it can be evaluated on compatible graphs with different numbers of nodes or different adjacency patterns. That is a statement about computation. Accuracy depends on the learned rule, features, graph construction, and training/test distributions.
For a new grid topology, compatible tensor dimensions are not enough. Changed connectivity, feature definitions, operating regimes, or measurement availability may change useful relationships. Our example establishes none of those real-system relationships; the original paper's public benchmarks do not certify a particular grid application.
A defensible evaluation plan makes these decisions before inspecting final test results:
- Name the transfer unit. Hold out whole topologies for unseen-topology claims, or declare a same-graph protocol. For temporal transfer, state the cutoff and correlated-sample grouping.
- Define the information boundary. Fit preprocessing on allowed training data. State whether test features or edges enter pretraining; unlabeled access is still access.
- Compare matched baselines. Use the same downstream labels, splits and tuning budget for random initialization, a supervised baseline, and pretraining. Separate frozen-probe and fine-tuned results.
- Report the relevant outcome. Choose metrics and failure slices in advance; include multiple seeds and uncertainty. Report topology-level variation separately from reconstruction diagnostics.
CL-010 · Methodological recommendations inferred from the mechanism and inductive/transductive distinction. This plan has not been executed.
Keep the method names precise
Generic masked autoencoding is a broader pattern. Vision MAE, for example, encodes visible image patches with an asymmetric design; its exact token routing should not be substituted for GraphMAE's graph path.
Original GraphMAE is the feature mechanism traced here. GraphMAE2 adds multi-view random re-masking and latent representation prediction. Those additions differ from original GraphMAE's same-node re-mask.
“GraphMAE+Edge” does not identify a method by itself. A user-specific variant needs its own code, objective, protocol and evidence. Neither the name nor the optional chemistry branch establishes what that variant implements or how it performs.
CL-015 · He et al., Masked Autoencoders, §3
CL-009 · Hou et al., GraphMAE2, §2.2 and Figure 2
CL-011 · User-specific variant remains unverified. No private research results are inferred.
Try it on a document graph
A new graph has text boxes as nodes and reading-order links as edges. Each node stores box area and ink mass in fixed units. Your prescribed reconstruction doubles both entries at every selected node. You get zero SCE. A downstream task needs absolute box area.
What has the reconstruction score established—and what has it missed? How would you evaluate a claim about unseen document layouts?
Work through the transfer answer
Positive doubling preserves every vector direction, so zero SCE establishes directional agreement for nonzero rows. It does not establish correct area or ink mass. Their ratio is preserved; their magnitudes are not. Check the downstream target directly and include per-feature or norm error as a diagnostic.
For unseen-layout transfer, group documents or templates into disjoint train, validation and test sets before fitting. State whether test pages participate in pretraining. A same-page label split and a held-out-template evaluation answer different questions. Compare frozen and fine-tuned encoders against matched baselines, then report measured results and uncertainty. Nothing in our six-node arithmetic supplies those results.
Return to B: we withheld its row, retained its target, routed context through a graph encoder and re-masked decoder, and scored selected reconstruction directions. Every later transfer claim must add evidence beyond that computation.
Glossary
- Graph and adjacency
- names nodes and connections. Our graph is undirected, without edge features.
- Feature row
- describes node . Here , with dimensionless synthetic channels.
- Mask set
- selects training targets. Corruption and loss selection are separate uses of this set.
- Representation
- is an encoder output; it need not have the input dimension.
- Re-masking
- Zero the projected representation at the same selected nodes before the graph decoder.
- SCE
- Average over selected nodes, with an explicit zero-vector policy.
- Prescribed reconstruction
- A chosen vector for inspecting the objective. No learning algorithm produced the lab's vectors.
Reproduce the arithmetic
The canonical numerical module (local copy) powers both the live inspector and static comparisons. It uses native JavaScript numbers, fixed arrays and no randomness. The small floating-point clamp keeps cosine within its mathematical range; zero vectors are rejected. This differs from the author's epsilon-normalized tensor code.
node lab.mjs
node --test model.test.mjsRun these from this guide's site directory with Node.js. lab.mjs (local copy) prints inputs, baseline, all control states and transfer checks as deterministic JSON. It does not fetch data or train weights. The numerical checks (local copy) include all 36 UI configurations and invalid boundaries.
Claim-level evidence ledger (local copy) · Concept blueprint (local copy) · Lab provenance (local copy)
Sources
- Hou et al. (2022). GraphMAE: Self-Supervised Masked Graph Autoencoders.
Original paper, arXiv v3, §3. Benchmarks have their own datasets and protocols.
- THUDM/GraphMAE: core encoder–decoder implementation.
Pinned commit b14f080c919257b495e3cb6474286d5252d6a635. Input token, corruption, projection, re-mask, decoding and embed.
- THUDM/GraphMAE: SCE implementation.
Normalize, dot, residual power, mean. Standalone alpha default differs from configured arguments.
- THUDM/GraphMAE: arguments.
CLI defaults mask_rate .5, replace_rate 0, alpha_l 2; dataset settings may override them.
- THUDM/GraphMAE: dataset configuration.
Dataset-specific settings, not a universal recommended mask ratio.
- THUDM/GraphMAE: inductive training and evaluation.
Inspect train/validation/test loaders and frozen representation evaluation.
- THUDM/GraphMAE: chemistry pretraining.
Separate optional mask_edge branch; do not generalize one path to the whole repository.
- Gilmer et al. (2017). Neural Message Passing for Quantum Chemistry.
§2, shared message/update formulation. Our mean aggregation is illustrative.
- Veličković et al. (2018). Graph Attention Networks.
§2, attention-weighted neighborhood aggregation.
- Hou et al. (2023). GraphMAE2: A Decoding-Enhanced Masked Self-Supervised Graph Learner.
§2.2 and Figure 2, multi-view random re-masking and latent representation prediction.
- He et al. (2022). Masked Autoencoders Are Scalable Vision Learners.
§3, image patch masking and asymmetric architecture.
- PyTorch: torch.nn.functional.normalize.
Epsilon-protected normalization. Checked 4 September 2026; lab instead rejects zero norm.