Skip to content

Latest commit

 

History

History
151 lines (107 loc) · 6.53 KB

File metadata and controls

151 lines (107 loc) · 6.53 KB

Encephagen: Research Development Report — Day 7

Date: April 7, 2026 Author: edvatar (toroleapinc) Repo: https://github.com/toroleapinc/encephagen


1. Summary

Day 7 achieved the core architecture that makes the fly project work: specific neural circuits producing specific behavior from their wiring + calibrated weights.

Built an 80-neuron spiking CPG with biologically identified interneuron classes from the mammalian locomotor CPG literature, optimized its weights with CMA-ES, and integrated it into the newborn demo. The stepping reflex now comes from real spiking neurons, not a rate-model equation.


2. Key Insight: Why the Fly Works and We Didn't

Research revealed the fundamental answer:

The fly's behavior comes from SPECIFIC neuron-to-neuron wiring. The grooming circuit is 4-5 neurons deep: touch bristle → sensory neuron #12483 → interneuron #89412 → motor neuron #112034 → leg muscle. Each neuron has ONE job. Each synapse has a known weight and sign.

Our 16K cortical brain has NO specificity. 200 random neurons per region, connected by macro-scale routing. No neuron has a specific job. The wiring says "somatosensory connects to motor" but not "this touch neuron connects to this muscle neuron."

The solution: Build SPECIFIC small circuits for SPECIFIC behaviors, like the fly does. Don't try to get general cortical computation from macro-scale data — build identified circuits.


3. Spiking CPG with Identified Interneuron Classes

Architecture (from Rybak et al. 2015, Danner et al. 2017, Kiehn 2016)

80 LIF neurons organized as:

Per hemicord (left and right):
  Shox2 Flexor RG (5 neurons) ←→ Shox2 Extensor RG (5 neurons)
     ↓ mutual inhibition → oscillation via spike-frequency adaptation
  V1 (4 inh) → inhibits extensor MN during flexion
  V2b (4 inh) → inhibits flexor MN during extension
  Flexor MN (5) ← driven by flex_rg + tonic drive
  Extensor MN (5) ← driven by ext_rg + tonic drive

Commissural (crossing midline):
  V0d (3 inh): flex_rg → contralateral flex_rg inhibition → L-R alternation
  V0v (3 exc): via V2a → contralateral inhibition → L-R alternation
  V3 (3 exc): symmetry enforcement

The Tuning Challenge

The architecture is correct from neuroscience. But getting the weights right required optimization:

  1. 2-neuron half-center test: Proved mutual inhibition + adaptation = oscillation (corr=-0.65) ✓
  2. Full 80-neuron circuit: Multi-population cascade inhibition killed oscillation ✗
  3. Simple ES (Exp 36): Found intermittent alternation (fitness 2.385, verification 0.296)
  4. CMA-ES (Exp 37): Found sustained oscillation (fitness 5.505, verification 2.380) ✓

This IS the Fly/Worm Approach

The parallel is exact:

  • BAAIWorm used parameter optimization on a biophysically correct C. elegans circuit
  • Eon Systems used connectome-derived weights (EM synapse counts) — evolution already optimized them
  • We used CMA-ES on a biophysically correct mammalian CPG circuit
  • All three: correct architecture + calibrated weights → behavior

4. Experiments

Experiment 36: Simple Evolutionary Strategy

30 generations × 15 individuals. Best fitness 2.385 during search, but verification on 30K steps: 0.296. Oscillation intermittent, not sustained.

Experiment 37: CMA-ES

40 generations × 15 individuals. Best fitness 5.505 during search, verification on 30K steps: 2.380 — 8x better than simple ES. Sustained partially-alternating motor output.

Key optimized parameters:

  • Mutual inhibition: -2.35 (flex→ext), -1.22 (ext→flex)
  • Adaptation: beta=2.92, tau=57ms
  • Drives: flex=16.8, ext=9.3, MN=11.1
  • Reset voltage: 3.1 (burst tendency)

5. Integration

The optimized spiking CPG replaces the Matsuoka rate-model in the newborn demo:

python newborn.py --spiking-cpg --video     # 80 spiking neurons for stepping
python newborn.py --video                     # Matsuoka rate model (comparison)

Both produce ~2.2x baseline survival on Walker2d. But the spiking CPG generates stepping from real neural dynamics with identified cell types, not a rate-model equation.

Full Architecture Stack

BODY (Walker2d / Humanoid, MuJoCo)
  ↕ proprioception + joint torques
BRAINSTEM (reflex arcs — hardwired)
  Righting, Moro, startle, stepping drive
  ↕ priority gating (basal ganglia)
SPINAL CPG (80 spiking neurons — CMA-ES calibrated)    ← NEW
  Shox2 rhythm generators + V0/V1/V2a/V2b/V3 + MNs
  ↕
CORTEX (16,000 neurons, 80 regions — observer)
  T1w/T2w gradient, HCP connectome, SC-FC validated

6. Cumulative Status (37 experiments, 7 days)

What we built:

Component Neurons Source Status
Cortex 16,000 HCP connectome (neurolib80) Observer (not controller)
Brainstem Hand-coded Neuroscience literature Controller (reflexes)
Spinal CPG 80 Rybak/Danner/Kiehn + CMA-ES Sustained oscillation
Body MuJoCo Walker2d/Humanoid 2.2x baseline survival

Key findings:

  1. Macro-scale cortex (80 regions) does NOT provide advantage over random wiring (0/33 experiments)
  2. Specific small circuits (80 neurons) CAN produce behavior from structure + calibrated weights
  3. The fly approach works: correct architecture + weight optimization → behavior
  4. Newborn behavior is SUBCORTICAL — cortex is observer at birth

The 先天 × 后天 at every level:

  • Spiking CPG: Architecture (先天) from neuroscience + CMA-ES calibration (后天) → sustained gait
  • Brainstem reflexes: Hardwired arcs (先天) keep body upright without learning
  • Cortex: Structure provides routing (先天), needs training to take over from reflexes (后天)

7. Files Changed

File Change
src/encephagen/spinal/spiking_cpg.py NEW: 80-neuron CPG with V0/V1/V2a/V2b/V3/Shox2/MNs
src/encephagen/subcortical/brainstem.py Brainstem reflexes + BG gating
experiments/36_optimize_spiking_cpg.py Simple ES optimization
experiments/37_cmaes_cpg.py CMA-ES optimization (the winner)
newborn.py Integrated spiking CPG option (--spiking-cpg)
visualize.py Walker2d + brain activity video
visualize_humanoid.py Humanoid + brain activity video
results/best_cpg_params_cmaes.npy CMA-ES optimized weights

Day 7. 37 experiments. The fly approach works at the spinal level: specific circuit + calibrated weights → behavior from spiking neurons. The cortex waits its turn — it will learn to take over as the newborn "grows."