
PigBrain: I Wired an RL Agent Like a Real Fruit Fly Brain Circuit — Here's What Happened
An RL agent with network topology copied directly from a real FlyWire connectome circuit (optomotor pathway), trained with PPO to dodge obstacles as a pig. Compared against a matched random-wiring baseline and an ablation on SageMaker, with a Bedrock agent supervising training. Honest result inside — including where the hypothesis didn't hold up cleanly.
# PigBrain: I wired an RL agent like a real fruit fly brain circuit
I built an RL agent whose network isn't a generic architecture — its connections
are copied directly from a real circuit in the FlyWire female fruit fly connectome
(the optomotor circuit: T4/T5 motion detectors → HS/VS cells → descending neurons).
It controls a pig in a simple dodge task, trained with PPO.
are copied directly from a real circuit in the FlyWire female fruit fly connectome
(the optomotor circuit: T4/T5 motion detectors → HS/VS cells → descending neurons).
It controls a pig in a simple dodge task, trained with PPO.
**The question:** does a network shaped like a real evolved circuit learn faster
than a same-size, same-connection-count random network?
than a same-size, same-connection-count random network?
· The result, honestly
- The connectome-wired network converged on 6/6 training seeds; a matched random
network only converged on 4/6, and did so ~1.5x slower.
- But the wiring pattern alone isn't what's responsible — an ablation using the
real wiring with randomized initial weights actually did *worse* than the random
baseline (1/3 seeds). The real **synapse strengths**, not just the connection
structure, carry the benefit.
- Among runs that did converge, final performance was similar across all variants.
- 6 seeds is limited statistical power, and RL runs weren't bitwise-reproducible
across my laptop vs. SageMaker — so I'm not overclaiming a clean win.
network only converged on 4/6, and did so ~1.5x slower.
- But the wiring pattern alone isn't what's responsible — an ablation using the
real wiring with randomized initial weights actually did *worse* than the random
baseline (1/3 seeds). The real **synapse strengths**, not just the connection
structure, carry the benefit.
- Among runs that did converge, final performance was similar across all variants.
- 6 seeds is limited statistical power, and RL runs weren't bitwise-reproducible
across my laptop vs. SageMaker — so I'm not overclaiming a clean win.
·Stack
S3 for data/model storage, SageMaker for training (9 jobs, 3 variants × 3 seeds,
ap-south-1), Bedrock (Claude Sonnet 4.5) as a supervisor agent that reads real
training logs, queries the connectome graph, and can trigger retraining.
ap-south-1), Bedrock (Claude Sonnet 4.5) as a supervisor agent that reads real
training logs, queries the connectome graph, and can trigger retraining.
Bonus: rendered the actual circuit in 3D from real FlyWire neuron skeletons
(631 neurons), with the RL critic's reward-prediction error visualized through
real dopamine neuron activity — see the repo for the video.
(631 neurons), with the RL critic's reward-prediction error visualized through
real dopamine neuron activity — see the repo for the video.
Full writeup, visuals, and code: [github.com/maasu-23/oink-oink](https://github.com/maasu-23/oink-oink)
Data: FlyWire connectome (Dorkenwald et al. 2024, Schlegel et al. 2024,
Matsliah et al. 2024, *Nature*), CC BY-NC 4.0.
Matsliah et al. 2024, *Nature*), CC BY-NC 4.0.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article