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.