Über uns
ANNA (Activation Nearest-Neighbour Alignment): a regulariser that organises a network's internal representations.
Maschinelles LernenGemessener Sternzuwachs
- in 24h
- Verlauf wird gesammelt
- in 7 days
- Verlauf wird gesammelt
- in 15 days
- Verlauf wird gesammelt
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
OriginalANNA: activation nearest-neighbour alignment
Blog post: Beautiful on the Inside
ANNA organises a network's internal representations without an external model. In each layer it:
- batch-normalises the activations over the batch;
- L2-normalises each sample;
- pulls each sample towards its k nearest neighbours, chosen by the network itself (no gradient through the choice).
The number of neighbours shrinks with depth.
z = (h − mean_batch(h)) / std_batch(h) per dimension
ẑ = z / ‖z‖ per sample
loss = task + λ · mean over layers l, anchors a, b ∈ kNN_l(a) of ‖ẑ_a − ẑ_b‖²
k_l = round(k_first · (k_last / k_first)^((l − 1) / (L − 1)))
- Neighbour search: 512 anchors per step, each searched against a pool of 1,024 samples.
- Strength: λ is off for the first 1k steps and ramps to full by step 2k.
- What it doesn't use: no teacher network, no variance floor, no anti-collapse term.
| strength λ | top-k k_first → k_last | |
|---|---|---|
| CPPN images | 0.3 | 128 → 5 |
| grokking, attention | 1 | 384 → 5 |
| grokking, MLP | 1 | 511 → 32 |
UFO baseline
The comparison is the UFO from Are UFOs Real? (github.com/fl97inc/are-ufos-real), a selective autoencoder trained alongside the network.
These are unchanged from the paper: autoencoder bottleneck 4, hidden 64, AE learning rate 1e-3, λ 0.3, selectivity 1 → 0.1 over 20k steps.
| setting | paper | here (every method) |
|---|---|---|
| output clamp | hard | straight-through |
| pixels per step | full image | 4,096 |
| initial weights | ×1 | ×0.5 |
| UFO λ warm-up | off before 1k, full by 5k | full from step 0 |
Grokking uses the paper's code and settings unchanged.
Results
1. Three-image comparison
results/images_summary.tsv, results/images_per_seed.tsv
- Setup: CPPN with 16 layers × 23 nodes, 50k steps, seeds 16–31. Runs are paired by initial weights across methods.
- Settings: one ANNA setting on all three images.
Each cell is ANNA / UFO / no regulariser:
| image | symmetry (mean) | image error (median) |
|---|---|---|
| butterfly | 0.92 / 0.91 / 0.83 | 0.0045 / 0.0059 / 0.0056 |
| skull | 0.94 / 0.78 / 0.67 | 0.0024 / 0.0040 / 0.0010 |
| cat | 0.67 / 0.62 / 0.35 | 0.0139 / 0.0138 / 0.0077 |
ANNA matches or beats UFO on symmetry at the same or lower error on every image. On the skull it is significantly better on both measures (paired Wilcoxon, p = 0.006 and 0.011).
2. Cat
results/cat_stages.tsv
Each method runs the same three stages:
- Organise: train 8 seeds and continue the most symmetric.
- Polish: strength 0.05, with learning-rate decay.
- Polish: strength 0.02, with learning-rate decay.
The organise strength is ANNA 0.3 and UFO 0.1.
| image error | symmetry | early-layer symmetry | |
|---|---|---|---|
| ANNA cat | 0.0063 | 0.87 | 0.99 |
| UFO cat | 0.0062 | 0.83 | 0.74 |
| reference: no regulariser, same seed and total steps | 0.0049 | 0.34 | 0.52 |
The reference comes from experiments/video.sh, which also produces the during-training frames.
3. Grokking
results/grokking_summary.tsv, results/grokking_runs.tsv
- Setup: the paper's x / y mod 97 task with a 2-layer transformer, 8 seeds per arm.
- Where ANNA acts: on the same representation as the UFO: the "=" token's attention weights or its MLP hidden units.
| median steps to grok | weight decay 0.03 | no weight decay |
|---|---|---|
| ANNA, attention | 16,000 | 26,500 |
| UFO, attention | 15,500 | 30,000 |
| ANNA, MLP | 37,500 | n/a |
| UFO, MLP | 30,000 | n/a |
| weight decay only | 104,500 | n/a |
Reproduce
pip install -r requirements.txt
bash experiments/images.sh # result 1
bash experiments/cat.sh # result 2
git clone https://github.com/fl97inc/are-ufos-real third_party/are-ufos-real
bash experiments/grok.sh # result 3
bash experiments/video.sh # during-training frames + the unregularised cat
- Outputs: each script writes its runs to
runs/and its tables toresults/. - Reproducibility: training is chaotic, so a rerun matches in distribution, not seed by seed.
- Offset check:
python analysis/offset_share.py ANNA:runs/images/<image>/anna UFO:runs/images/<image>/ufo none:runs/images/<image>/none. - Old TC (for the offset comparison) is commit
1b0cecd: run itsexperiments/images.sh, then pointanalysis/offset_share.pyat its TC runs.
Files
anna/cppn.py |
CPPN, rendering, metrics |
anna/regularisers.py |
ANNA and the UFO |
anna/train.py |
CPPN trainer: ANNA, UFO or none; --resume for polish stages |
grok/anna_grok.py |
grokking: the paper's code for weight decay and the UFO, plus ANNA on the same representation |
experiments/ |
one script per result |
analysis/, grok/summary.py |
turn runs into the results/ tables; video.py renders frames, offset_share.py checks for a shared offset |
Metrics
- Symmetry: the mean |correlation| between each non-constant node's activation map and its mirror image, per layer, then averaged over layers.
- Early-layer symmetry: the same over layers 1–3.
- Image error: mean squared error of the painting over 256 × 256 pixels.
Ähnliche Projekte entdecken
Wird geladen…