experiments

Mini System One driver: a neural network with hand-written weights

A tiny experiment inspired by Sparks of Weight-Space Programming (LLMs reading and writing neural network weights directly) and System One models like TypeSafe AI’s Jev (state in, a typed choice with probabilities out).

Every weight in the two “hand-written” networks was written by reasoning about what each layer should compute. Nothing is trained or fitted to data.

The task

A 3-lane road scrolls toward a car. The model sees the car’s lane and the next 5 rows of obstacles (18 numbers) and returns one of left, stay, right with probabilities. Hitting an obstacle ends the run. A drivable path always exists.

Results (500 roads, max 300 steps)

Driver Avg steps Full runs
Random 5.9 0%
Trained net, REINFORCE, 300 episodes 14.4 0%
Trained net, REINFORCE, 3,000 episodes 27.2 0%
Hand-written, shallow (198 weights, 2 layers) 82.3 2.4%
Hand-written, deep (2,217 weights, 11 layers) 299.2 99.6%
Search planner (System 2) 299.2 99.6%

How the networks work

Shallow: one hidden unit per (current lane, action) pair. A large gate weight on the lane input switches the unit on only in that lane; the unit’s value is how clear the target lane looks, with nearer rows weighted more heavily. It fails when the only gap is two lanes away.

Deep: the layers compute reachability row by row, from the far end:

S[r][l] = free[r][l] AND (S[r+1][l-1] OR S[r+1][l] OR S[r+1][l+1])

With 0/1 values, ReLUs do the logic: OR(x,y,z) = s - ReLU(s - 1) where s = x+y+z, and AND(a,b) = ReLU(a + b - 1). In effect, the planner’s search is compiled into a single forward pass: a System 1 network that makes the same decisions as System 2.

Caveats

Run it

pip install numpy
python mini_jev.py

Open demo.html in a browser to watch the networks drive. It runs the same weights. It is also live at https://gaberger.github.io/experiments/mini-jev/demo.html, and DEMO.md explains what it shows.