Weight-Space Programming builds neural networks like a 1990s researcher
Pangram verdict · v3.3
We believe that this text is a mix of AI and human-written content.
AI likelihood · overall
MixedArticle text · 1,757 words · 32 segments analyzed
The writing aspect of WSP turns out to be quite a history lesson. Intro Weight-Space Programming still has me pretty intrigued. The basic idea is that frontier LLMs can read, write and edit the weights of neural networks. There's nuance to what's going on, but it feels like there's a lot of new ground to explore. In the original blog post, beyond the reading and editing experiments, the authors had GPT-6 Astra build a network to play Go from scratch, then improve it by playing practice games, and editing the weights based on analysis of its losses. That loop of writing, testing and editing feels like a new way to train a network, something like LLM Descent. But is it? In this article, I run my own weight-writing experiment with Claude Fable 5.2 on a familiar image classification problem. Look closely at what the model builds, and it turns out to be an interesting history lesson in hand-crafted, pre-deep-learning techniques. With that new lens on weight-space programming, I also study the Go network that Astra built in the original article, and find something very similar. Building an image classifier with LLM Descent MNIST is the OG image classification problem. The goal is to label each handwritten digit, 0 to 9. Similar to the Go test in the original Weight-Space Programming post, I built a test with a fixed CNN, then prompted Claude to write code that sets all its weights from scratch, with a few rules that include no fitting, regression, or searching. Drawing filters and templates by hand, from formulas or strokes, is explicitly allowed. It's a considerably stricter setup than Astra had for Go, with no PyTorch and no practice games, only its training loss, accuracy and confusion matrix after each attempt. The tests in this blog post were run with Claude Fable 5.2, which performed considerably better than Opus 5.5. Claude starts with no weights at all, and has to set every one of this network's 5,994 weights "by hand": model = nn.Sequential( nn.Conv2d(1, 8, 5), # conv1: 1x28x28 -> 8x24x24 nn.ReLU(), nn.MaxPool2d(2), # 8x24x24 -> 8x12x12 nn.Conv2d(8, 16, 5), # conv2: 8x12x12 -> 16x8x8 nn.ReLU(), nn.MaxPool2d(2), # 16x8x8 -> 16x4x4 nn.Flatten(), # 16x4x4 -> 256 nn.Linear(256, 10), # fc: 256 -> 10 class logits ) You can read the whole prompt on GitHub.
Claude's code runs in a sandbox that can only import NumPy, SciPy and math.
Once it returns the weights, a test harness runs the network on the training and test images.
Claude has up to 50 steps, and at each one it sees all the feedback so far.
The training set is 10,000 images from MNIST's official training split. Claude never sees the 10,000 official test images or how it scores on them, and the network with the lowest training loss gives us the final test score.
Here's an example of the feedback it gets after its first attempt: Step 1 of 50: training loss 1.0324, accuracy 0.7147. Confusion matrix (rows: true digit, columns: predicted digit): true \ predicted 0 1 2 3 4 5 6 7 8 9 0 723 0 39 0 0 42 181 0 5 1 1 4 1022 23 0 3 4 0 8 0 0 2 30 5 461 176 3 12 9 13 271 10 3 2 0 8 687 0 125 51 4 133 20 4 7 19 14 6 768 0 35 10 22 102 5 10 5 13 45 2 492 312 6 29 1 6 41 17 19 1 266 8 603 0 10 2 7 8 2 21 45 2 7 13 906 11 75 8 15 19 86 5 5 4 60 27 714 74 9 15 9 1 4 1 19 46 82 13 771 History (training set, 10,000 images): step | loss | accuracy ---- | ---- | -------- 1 | 1.0324 | 0.7147 At most 49 steps left. Reply with the complete build_weights() for step 2 in one Python code block.
The descent I ran it three times.
Though I have early stopping configured to stop when the training loss stops improving, all three runs descend for the full 50 steps, still improving when they run out, and land around 90% on the test set. Amazingly, that's close to where a training run with Adam gets to after 50 gradient steps. A 1990s computer-vision pipeline In 1998, LeCun's paper that introduced MNIST described that era's approaches thus far as "a fixed feature extractor and a trainable classifier", where the feature extractor "is often entirely hand crafted" (LeCun et al., 1998). Accuracy, he wrote, "is largely determined by the ability of the designer to come up with an appropriate set of features", which is "a daunting task which, unfortunately, must be redone for each new problem."
That daunting task is exactly what Claude takes on.
All three runs built the same kind of pipeline, though not from the same parts: Technique Run 1 Run 2 Run 3 Hand-drawn digit templates step 1 step 1 step 1 Log-odds (naive Bayes-style) scoring step 1 step 11 step 2 Loop or hole detectors step 3 step 3 - Corner or concavity detectors step 3 step 3 - Stroke-endpoint detectors - - step 21 First measurement step step 4 step 4 step 5 Classifier built from its measurements step 5 step 11 step 13 Measurement steps in total 22 24 27 The first step at which each run's network uses the technique.
Let's follow run 1, step by step, based on Claude's replies and reasoning. It's the best of the three, at 91.3%, but the other two follow a similar path, measuring their way from hand-drawn templates to a classifier.
1.
Hand-drawn templates (steps 1 to 3) Claude starts like a 1990s computer vision engineer.
Its first layer is a set of line detectors at four angles, written from formulas.
They're cousins of the Sobel filter, a classic way to find edges in an image, which 1990s digit recognisers started with (Favata and Srikantan, 1996). Each detector is a 5×5 grid of weights in the first convolution layer. As it slides across the image, it multiplies the 25 pixels under it by its 25 weights and adds them up, so it scores high wherever there's a stroke at its angle, and zero on blank paper. Fable fills in four of the layer's eight filters this way and leaves the other four at zero for later. Its second layer adds up each detector's map over patches of the image, so every image ends up as a 4×4 grid of cells saying which stroke directions appear in each. Then it draws each digit by hand, as a few strokes in code, and turns each drawing into the same kind of grid: how likely each stroke direction is in each cell. Those tables become the final layer's weights, so it scores every image against all ten tables. The final layer is a 10 by 256 grid of weights, with one row for each digit's table. The weights are the log-odds of that table, scaled down by a temperature. The log-odds turn each probability into a score that can simply be added up, and the temperature turns all the scores down, so the network isn't overconfident. This is template matching - one of the oldest approaches in character recognition (Mori et al., 1992). The scoring works like naive Bayes, which treats each feature as separate evidence for each digit. Bayesian rules for reading characters go back to 1957 (Chow, 1957).
Its first network gets 71% on the test set.
Redrawing the digits the confusion matrix says are wrong brings it to 77%.
See it for yourself: steps 1 to 3 Step What happened Files 1 Line detectors and hand-drawn templates, scored as log-odds reply · thinking summary · code · results 2 Redraws the templates the confusion matrix says are wrong reply · thinking summary · code · results 3 Adds a closed-loop detector built from four corner filters reply · thinking summary · code · results 2.
Unit-testing the loop detector (steps 4 to 9) An old-school model engineer would have studied the digits to see where their features go wrong.
We haven't given Claude the ability to do that in this test, but at step 4, it tries an interesting approach, where it stops classifying for a step and tests a loop detector (a feature for closed loops, like the ones in 0, 6, 8 and 9) on its own: I cannot tell that from a confusion matrix where everything is mixed together, so this step tests the detector on its own, like a unit test.
It rewires the output layer so that each "predicted digit" means how strongly, and where, the loop detector fired. Each row of the confusion matrix then becomes a histogram of the loop detector for one true digit.
One step later, it knows the detector fires on 83% of 8s. At steps 6 and 7, it tests its own drawings the same way, putting variants of each digit head to head.
In a way, this is kinda cheating, but then again it doesn't break the rules.
The code doesn't run the network or fit anything, or even see an image. And hey: the test set is untouched, so the scores are still honest.
See it for yourself: steps 4 to 9 Step What happened Files 4 Tests the loop detector on its own reply · thinking summary · code · results 5 Puts the loop detector back, weighted by what it measured reply · thinking summary · code · results 6 Tests the size and slant of its drawings, head to head reply · thinking summary · code · results 7 A tournament between variants of 2 and 3 reply · thinking summary · code · results 3.
Corners (steps 10 to 18) Next, it turns the corner detectors inside its loop detector into features of their own: four corner shapes where strokes meet (┌ ┐ └ ┘).
Handwriting recognisers relied on shape features like these (Trier et al., 1996) (Favata and Srikantan, 1996).
At first it guesses how often each one shows up in each digit.
When that stalls at about 81%, it measures them instead, three steps in a row, and sets their weights from the results.
Three measurement steps on the corners gave more than many steps of guessing, and they showed that some of my hand-drawn expectations were far off.
By step 18, it's at 83%.
Pretty incredible, if you ask me.