ESP32-S3 Bench Guide
ESP32-S3 N16R8 bench guide: live pinout, lessons, simulators and the bench log.
A spiking simulation of a real fruit fly brain learns a rhythm game through dopamine: FlyWire connectome, brain-style learning vs a trained readout, and wiring and dopamine controls.
Translation pending
EducationPython · JavaScriptGitHub @bsgelmanOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
Loading the full README. The saved excerpt is shown below.
A spiking model of a real fruit fly brain learns a three-lane rhythm game, in the style of Guitar Hero, by trial and error. The learning happens inside the simulated brain: dopamine strengthens the synapses that led to a hit and weakens the ones that led to a mistake.
33% of notes hit before practice, 99.3% after 30 songs, and 100% on a song it never heard. With its dopamine neurons blocked, it stays at 33%.Read the full README ↗A spiking model of a real fruit fly brain learns a three-lane rhythm game, in the style of Guitar Hero, by trial and error. The learning happens inside the simulated brain: dopamine strengthens the synapses that led to a hit and weakens the ones that led to a mistake.
Live demo: bsgelman.github.io/fly-hero
33% of notes hit before practice, 99.3% after 30 songs, and 100% on a song it never heard. With its dopamine neurons blocked, it stays at 33%.
The simulation has 6,900 neurons (3,275 in the brain and 3,625 in the nerve cord) and 6,419,481 synapses from the Janelia and Google male fruit fly connectome. Every neuron that fires flashes on the brain view as it happens, all the way down the nerve cord.
Janelia/Google male CNS connectome (public data)
│
▼ extract_subgraph.py connectome → 6,900 neurons, 6,419,481 synapses
▼ flyhero/sim.py synapses → spiking neurons, 1 ms steps (NumPy)
▼ flyhero/game.py notes → the eye neurons for that lane fire
▼ flyhero/agents.py spikes → key press, reward, dopamine, synapse update
▼ js/ same model → runs live in the browser: game, brain view and charts
| File | Lines | Job |
|---|---|---|
tools/extract_subgraph.py | 126 | Picks the eye, memory, dopamine, output and nerve cord neurons from the male CNS and writes the network |
flyhero/sim.py | 170 | Leaky integrate-and-fire neurons on the real synapse list, plus the shuffled and random wiring controls |
flyhero/game.py | 87 | Songs, rewards and a millisecond-level game loop |
flyhero/agents.py | 105 | Bio-RL (dopamine learning inside the brain) and Deep-RL (a readout trained with REINFORCE) |
flyhero/run_experiments.py | 88 | Runs every learner and control in parallel and writes data/results.json |
flyhero/train_fly.py | 30 | Trains the fly you play against |
flyhero/test.py | 106 | Checks the neuron model, wiring controls, rewards and learning, and that the browser version matches |
js/sim.js, js/game.js, js/agents.js | 327 | The same model ported line for line, so it runs live in the browser |
js/app.js | 285 | The page: watch the fly learn, you vs fly, compare learners |
js/brain.js | 53 | Brain and nerve cord drawing |
The model is Python with NumPy as its only dependency. Browsers can't run it live, so the page runs a JavaScript port with no frameworks or build step. Both use float64 and the same random number generator, and flyhero/test.py checks that they produce identical spikes and key presses from the same seed.
Each learner practised for 30 songs (the same song 30 times), repeated 5 times from scratch. Scores are the share of notes hit.
| Learner | Before practice | End of practice | New song |
|---|---|---|---|
| Bio-RL, real wiring | 33.1% | 99.3% | 100.0% |
| Bio-RL, shuffled wiring | 21.9% | 21.9% | 27.2% |
| Bio-RL, random network | 15.0% | 25.9% | 26.2% |
| Bio-RL, dopamine blocked | 31.9% | 33.3% | 35.9% |
| Deep-RL, real wiring | 23.1% | 99.0% | 97.4% |
| Deep-RL, shuffled wiring | 23.1% | 82.8% | 75.9% |
| Deep-RL, random network | 23.1% | 100.0% | 100.0% |
| Deep-RL, real wiring, 150 songs | 21.9% | 98.5% | 95.7% |
End of practice is the average of songs 26 to 30 (146 to 150 for the last row). New song is a different song, played once with learning switched off.
Full numbers, spreads and the reasoning behind each control are in docs/lab-notebook.md.
It reads notes instead of memorising the song. The fly only sees which lane a note is in, never where it is in the song. That is why it scores the same on a song it never practised.
Dopamine is made of simulated spikes. After each press, reward (PAM) or punishment (PPL1) dopamine neurons fire in proportion to how surprising the result was, and their spike counts set how much the synapses change. Blocking dopamine silences those neurons, and learning stops.
Mistakes can't wipe out what it learned. Simple dopamine rules often fail because early mistakes far outnumber hits. Here a change shrinks to zero once a pathway already predicts its reward, only synapses that just fired can change, waiting changes nothing, and synapse strength is capped.
One fly for everything. The wiring, the sign of every synapse, the drawing and each neuron's position all come from the Janelia and Google male CNS connectome, so every flash is at that neuron's own cell body.
The nerve cord fires too. 3,625 nerve cord neurons receive the brain's descending neurons, so activity travels down the neck when the fly acts. The cord only listens: nothing flows back into the brain, and the wiring controls leave it untouched. Replaying runs with and without it gave identical key presses.
Settings were fixed before the results. Every learner and control runs through the same code with the same parameters, set once before the experiments.
Each note is a single decision, so this is reward prediction error learning, not learning over long sequences. In real flies, dopamine mostly weakens these synapses, while here reward strengthens them. Dopamine reaches the whole memory centre at once rather than individual compartments. Only the right half of the brain is simulated, and the nerve cord only receives signals from the brain.
git clone https://github.com/bsgelman/fly-hero.git
cd fly-hero
python tools/serve.py
Open http://localhost:8766.
pip install -r requirements.txt
python -m flyhero.test # checks, about 4 min (the browser check also needs Node)
python -m flyhero.run_experiments # every learner and control, about 55 min on 22 cores
python -m flyhero.train_fly # retrains the You vs fly opponent
To rebuild the network from the raw connectome, download three files from the Janelia male CNS downloads into data/raw/ and run python tools/extract_subgraph.py (needs pandas and pyarrow):
body-annotations-male-cns-v1.0-minconf-0.5.feather, saved as mcns_annotations.featherconnectome-weights-male-cns-v1.0-minconf-0.5.feather, saved as mcns_weights.feather (about 1 GB)body-neurotransmitters-male-cns-v1.0.feather, saved as mcns_neurotransmitters.featherCode is under the MIT License. The network and brain positions are derived from the Janelia and Google male CNS data (CC-BY), credited above. The typeface is Atkinson Hyperlegible Next under the SIL Open Font License (fonts/OFL.txt).