Writing neural networks by hand

Can an AI set a neural network's weights directly, by reasoning, instead of training it?

This question was inspired by a recent article from MIT, in which network weights are written and edited directly by an AI model. We call it the original article below. A second article, Qwenputer, which compiles a working CPU into a language model's weights, shaped the later direction of this work. The code in this small experiment follows the original article's ideas on a laptop, with Claude Opus 5.5 designing the networks and writing the code.

What we did

A neural network turns its input into an output through layers of simple units. Each connection between units has a weight, a number, and the weights decide what the network does. Normally they're found by training. Here, Claude set them by hand, so they can play simple 2D games.

The three games

Breakout An existing simplified Atari game (from MinAtar) on a 10 by 10 grid. The paddle at the bottom bounces the ball up to break bricks. Score: bricks broken. How the network works · Replays
Airplane Made for this lab. The plane on the bottom row dodges falling reds, which end the game, and collects greens, worth a point each. How the network works · Replays
Walled In Made for this lab. Two players move at the same time, each leaving a wall behind. The first to crash loses. How the network works · Replays

The three experiments

Writing game networks, and comparing them with training

For each game, Claude designed a strategy and wrote a script that sets every weight of a small network. The network's size was fixed in advance so that the same network could also be trained, for a fair comparison. These handwritten networks were then compared with trained ones, mixed with training, and matched against an ordinary program.

Blind and revised
The first attempt was blind: the network was never run before it was scored. Later, revised attempts could run it on practice games and fix what went wrong.
Flood-fill network
Walled In's small network couldn't afford to look even one cell ahead, so Claude built a second shape. Like the paint-bucket tool in a drawing program, it spreads outwards from each player until it reaches walls, to measure how much of the board each move would claim.
PPO
A standard reinforcement learning method. It trained networks of the same shapes from random weights, learning from the game's score alone.
References for scale
A stronger player for each game, not one of ours: the original article's own network for Breakout, a search program for Airplane that checks every visible row, and a lookahead program for Walled In that compares how much of the board each move would reach first.
Fine-tuned and hand-edited
A handwritten network was fine-tuned, trained further with PPO from its handwritten weights. A trained network was hand-edited: Claude studied its weights and rewrote some units to fix its mistakes.
Program twin
The flood-fill network's strategy for the Walled In game, also written as an ordinary program, then compared with the network move by move.

Reading networks back

A separate Opus 5.5 session was given three of the game networks and asked which game each one plays, from their weights alone.

The setup
It was told all three networks had been trained to play a game, which was false for two because these two networks were hand-written. It wasn't told the games' names.
No forward passes allowed
A forward pass means running a network on an input and reading its output. This session could only read the weights, never run the networks.

Editing a language model

The goal was to change one fact inside a small language model with no training: make it say the Eiffel Tower is in Rome, while keeping everything else it knows.

The model
SmolLM2-135M-Instruct, a small open language model tuned for chat. The false answer was chosen on purpose, as a clear test.
How
Edits were designed first from the weights alone, then with a limited number of forward passes.

What we observed

Weights can be written, not trainedClaude designs an algorithm for the game, then works out the weights that carry it out. Networks written blind, never run before scoring, played every game.
Training fell shortNetworks of the same size trained with reinforcement learning scored far below the handwritten ones in two of the three games, and a little below in the third. Training ten times longer barely helped.
Weights reveal the gameFrom the weights alone, with no forward passes, Opus 5.5 named Breakout, described Airplane and spotted which networks were written by hand. It took Walled In for single-player Snake.
Fact edits work, with leaksReading a real language model's weights alone didn't produce a working edit. A few dozen forward passes did: the model now puts the Eiffel Tower in Rome, but says France's capital is Rome too.

A network can only run a strategy it has room for

The small Walled In network couldn't afford to look even one cell ahead, so it followed a fixed route. The flood-fill network, arranged to repeat one small rule across the whole board, played far better, even with fewer weights. What matters is the right shape for the strategy, not just size.

Playing games fixed the blind designs

The blind networks had mistakes that only showed in play. Letting Claude run practice games, see how they were lost and fix the cause improved every network, some of them several times over.

A handwritten network matched its program twin exactly

The flood-fill network and the program written from the same design chose the same move in every position tested, and played the same games, move for move. See the comparison.

A trained network was improved by hand

Claude found the few positions where the trained Walled In network kept crashing and rewrote some of its units to handle them. The edited network beat the original most of the time, but it was a targeted patch: it didn't get better against the other opponents.

Training could only polish a handwritten network

Fine-tuning improved the flood-fill network slightly but couldn't change its strategy. Its units were set as hard on/off switches, which give training nothing to adjust. Softer weights would leave room for training, at the cost of less exact logic, but that wasn't tested.

What we conclude

Training or design: a trade-off

For a complex game, there are two ways to get a good player. Training needs a simulator and a lot of compute, but no one has to invent the strategy: it has played dozens of Atari games about as well as a professional human tester, and beaten the best Go players. Designing an algorithm needs an expert's insight, testing and tuning, but it gives a readable program. Once that program exists, writing it into a network's weights adds nothing, because the program already plays as well. Training has costs too: it needs tuning, and our own short runs fell far short. And as AIs get better at design, the expert's time may get cheap. Where working on weights does offer something code can't is in trained networks: patching behaviour that no one ever wrote down.

Network weights can run an algorithm

When Claude writes a network by hand, it first designs an algorithm and then compiles it into weights. So the same algorithm can also be written as ordinary code, as the flood-fill program shows.

A network's shape limits which algorithms fit

A network like ours, which runs once from input to output with nothing carried over (a feed-forward network), does a fixed amount of work per pass. So it can only run algorithms with a known upper bound on their steps. Running any algorithm needs memory and a loop, not just a larger network.

Memory means state carried from one pass to the next

In a language model, the attention layers keep what they computed for earlier words (the key-value cache) and look back at it. In Qwenputer, a kind of layer called DeltaNet keeps a running memory that holds the CPU's code, data and registers, and each generated word is one tick of its clock. A feed-forward network that feeds part of its output back in as input runs as a recurrent network. That costs the same at every step, while attention gets more expensive as the sequence grows. Attention's advantage is exact recall of any past token, and it's easier to train.

Writing networks by hand is unsurprising in principle, notable in practice

Neurons were shown to work as logic gates in 1943. What's new is an AI doing it by reasoning, at scale: the original article's model wrote a Breakout network's weights out by hand in one reply, with no code run, and a 1.5-million-weight Go network from a single script, with no forward passes.

Small networks can be read from their weights; larger ones need forward passes

Guessing the game worked from the weights alone. The language-model edit designed from the weights alone changed nothing, and the original article's attempt to tell a sycophantic language model from its weights alone failed.

A standalone handwritten network is mostly a demonstration

For a game strategy, code does the same job and is easier to read, debug and extend. Training may still beat hand design in hard games, as learned networks did in Go, though with search and enormous compute. This lab didn't test that.

The more promising directions work inside existing networks

One direction is compiling modules into a network, as Qwenputer adds a CPU to Qwen without tools or retraining. The other direction is fixing networks: the hand-edited Walled In network and the Eiffel Tower edit here, and the original article's fix of a car-driving network and its maths edit to a language model. All of these fixes worked. The original article's were broad: the car network then succeeded in every test run, and the language model's maths score rose several-fold. Ours were more targeted: the Walled In edit beat the original network but didn't help against other opponents, and the Eiffel Tower edit also changed a related fact.

The experiments in detail

1. Writing weights directly

For each game, Claude read the rules and wrote a script that sets every weight. The first attempt was blind: a hash code computed from its weights file was saved before the network ever ran, so it couldn't be changed after seeing results. Later attempts could watch games and fix mistakes.

The network's inputs say where everything on the board is: the ball, paddle and bricks in Breakout, the plane, reds and greens in Airplane, and the players and walls in Walled In. Claude worked out how to set the weights so that, layer by layer, the network turns that picture into a decision, with the best next move getting the highest output. Fitting each strategy into a small network took a few tricks of its own, which the game pages explain step by step.

BreakoutLookup tables and a two-column catch window AirplaneOne group of units per column, and a repeat rule hidden in the weights Walled InWhy a small network can't look one cell ahead, and a network shaped for the board that can Training and hand-editingPPO on a handwritten network, and a hand edit of a trained one

2. Compared with training

PPO, a standard reinforcement learning method, trained the same shapes from random weights. Each game has its own scale, so compare bars within a game only. Breakout and Airplane are scored in points per game. Walled In is scored as a percentage: a won game counts 1, a draw ½ and a lost game 0, averaged over 1,000 games against each of the three opponent programs and then over the three, so 50% means even. The same rule gives every Walled In percentage below.

These PPO runs were short, from 1M to 100M steps with one set of settings, so they show what this lab's training reached, not the most PPO could do. More steps alone helped little: Airplane's training score stopped rising at about 10M steps, and 100M steps scored 20.2, against 16.3 for the same seed at 10M. The original article's longer Breakout runs reached about 25, still far below the handwritten networks.

3. Training a handwritten network, and hand-editing a trained one

The best flood-fill network was trained further with PPO for 500k steps. Its units are deliberately all-or-nothing, so gradients through them are exactly zero, and only its 5 output weights could change. PPO nudged them, valuing the opponent's cells about 4% more, and its score against the opponent programs rose from 75.8% to 77.1%. Game by game, 75 games improved and 35 got worse: a small but real gain. Training polished the strategy, but it couldn't change it.

The reverse worked too. The small PPO network for Walled In is nearly deterministic, so just 8 board positions caused 99% of its avoidable crashes against itself. Rewriting 12 of its 64 units as exact checks for those positions made it score 81.5% against its original: 713 wins, 204 draws and 83 losses in 1,000 games not used to make the edit. It's a targeted patch, though, not a better player: against the other opponents it scores slightly lower than before. See both experiments, step by step.

4. Who beats whom

Walled In's players also met each other in a tournament. The six players were:

There was no single ranking. The lookahead program beats the flood-fill networks, which beat the 32-unit networks, which mostly draw with the program. Each cell is the row player's score against the column player over 1,000 games, counted the same way: a win 1, a draw ½, a loss 0.

5. Reading a network back

Opus 5.5 got three networks, was told they were all trained, and was asked what game each plays, from the weights alone, without running them.

NetworkOpus 5.5's guessVerdict
Breakout, handwrittenMinAtar Breakout, with high confidenceCorrect
Airplane, handwrittenDodge one kind of object, collect anotherRight game, different story
Walled In, trained with PPOSingle-player Snake, 65–70% confidenceMissed the opponent

Without being asked, it said the first two didn't look trained, and it was right. Read the findings.

6. Editing a real language model

One change to one matrix of SmolLM2-135M, with no training, was meant to move the Eiffel Tower to Rome, while keeping everything else. The false answer was made on purpose. The model passes text through 30 layers, and reads it in small pieces: "Eiffel", for example, is split into "E" and "iffel".

The approach wasn't invented here. It follows a published method, ROME (Meng and colleagues, 2022): first find where the model handles a fact by changing its internal values during forward passes and watching the answer, then edit one matrix with a rank-one change. That's the simplest kind of change to a matrix, and it works like a single rule: "when the layer's input matches this pattern, add this to its output". Claude's scripts follow the same two steps, and attempt 3 uses ROME's formula for the edit. Its success here likely owes a lot to having learned this research, as with the game networks, where it did best when it could read the game's code.

Weights onlyAn edit designed only by reading the weights, without running the model, changed nothing. Without seeing the model run, there was no way to tell where in its 30 layers the fact is handled, and the guess was wrong.
Wrong reasonRunning the model showed that the "iffel" piece triggers the fact, in the very first layer. Editing there made the model read "iffel" as if it were "Rome". It then answered Rome, but it also garbled the name in its replies.
Closest resultA later edit, found with more forward passes, works near the end of the model, at the point where the answer is about to be written. It steers that answer from Paris to Rome when the Eiffel Tower is the subject. The model now says the tower is in Rome, Italy, and all 30 unrelated facts tested stayed the same.
Side effectAsked "What is the capital of France?", the model now also says Rome. But other wordings of the same question often still get Paris: Rome came back for only 6 of 15 wordings we tried, and the largest city in France is still Paris. And it hasn't really learned that the tower moved: asked for the famous tower in Paris, it still names the Eiffel Tower. The edit redirects an answer rather than changing what the model knows.

A side question

How are Paris and Rome represented inside the model, if one edit can change the answer to some questions about France's capital but not others? A recent essay from Goodfire, Neural Networks Are Already Clean, argues that most concepts are encoded fairly cleanly in individual neurons, rather than spread across many of them in a tangled way. This lab didn't study that question, but a partial, wording-dependent side effect like this one is the kind of result that such work tries to explain.

See the replies side by side.

What this does and doesn't show

This is a small-scale experiment

Three small games, small networks, short training runs with one set of settings, and one edited language model. Each experiment was run once. Larger games and networks would be needed to see whether any of this scales.

It shows that an AI can turn an algorithm into a network's weights

At least for small networks: the clearest case behaved exactly like the program written from the same design.

It shows that an AI can reason about a network it can read and write

Knowing how networks are built, and able to write scripts that read and set weights, Claude designed networks and worked out what others do. It did best when it also had the game's source code.

It doesn't show that an AI can correctly edit any network just by looking at it

The language-model edit designed from the weights alone changed nothing. It took forward passes to make an edit work, and even then a related fact changed too.

It doesn't show that hand design beats training, or that weights beat code

Our training runs were short, and longer training has won in harder games such as Go. And for a game strategy, ordinary code does the same job.

The conditions favoured the handwritten networks

Claude read the games' code before writing weights, and designed two of the three games knowing a network would play them.

Everything else

Breakout replaysMedian games of every network Airplane replaysMedian games of every network Walled In replaysTypical games against each opponent Full READMEEvery result, caveat and link