Handwired: turn your regular JavaScript code into a neural net
Summary
Cheng Lou's Handwired compiles ordinary JavaScript into an exact neural network of ReLUs and weighted sums that needs no training, stays fully differentiable, and runs in a browser without a GPU.
Branches become arithmetic.
The ternary a > 4 ? 10 : 12 becomes above4 = relu(a - 4) - relu(a - 5), which blends both branches by a 1-or-0 weight.
A small desktop written in JS, transformed with Handwired.
Code is the net.
The circuit figure draws that arithmetic as wires and boxes, so the program itself is a two-ReLU network rather than a trained approximation.
Real apps compile.
The Mini OS demo, with lists, animation, drag, input, and pictures rendering to the DOM, compiles to 9,909 weights in 130 layers with zero training.
Differentiable means trainable.
The learned gallery unfreezes a compiled program's weights and trains them live, and JSON search runs as WebGPU kernels.
No training, exact yet also fully differentiable, runnable in a browser without GPU.
Highlights
The regex matching, JSON parsing & highlighting are all written in JS, then turned into WebGPU kernels for massive parallelism.
Read the original ↗Save to Sponge
Summarized with Sponge. Quotes are the author’s own words.