TRENCHFLY / docs watch it live

The brain

Measured: MaleCNS v1.0

The connectome is the male Drosophila melanogaster central nervous system reconstructed by Janelia's FlyEM team from electron microscopy: 165,122 traced neurons and 25,563,197 connections between them. We download the published tables with pinned checksums, keep only neurons with status Traced, and build a sparse adjacency matrix. The matrix is never edited. Its sign, its sparsity and its shape are the animal's.

Engineered: the nose subgraph

Most of those neurons drive legs, wings and the ventral nerve cord, which we never use. For daily work we cut the graph down to the olfactory pathway and everything within three hops of it on the way to the outputs:

Quantity Full graph Nose subgraph Share
Neurons 165,122 32,498 19.7 %
Edges 25,563,197 6,080,695 23.8 %
Synapses 124,025,046 34,618,384 27.9 %
graph.npz on disk 295 MB 70 MB

SHA-256 99345b6a62ddc82574c02439399793bac8472f9d75c4b52b75153bb64d32fcbb, built from traced-graph eff4093b…. Files: graph.npz (re-indexed CSR, same crow/col/counts/body_ids format), nodes.feather (all 36 columns), index_map.npy (32,498 subgraph → full indices, ascending so body IDs stay sorted), selection.json.

Base sets, using the measured rules from the T02 census (not the brief's wording — see docs/reports/T02.md):

Set Rule Neurons
ORN type starts ORN_ 2,635
Lateral horn type starts LH 2,028
Descending superclass == 'descending_neuron' 1,314
AL projection class == 'ALPN' 686
AL local class == 'ALLN' 420
AL other class in {ALIN, ALON} 38
Kenyon cells class == 'Kenyon_Cell' 4,064
MBON class == 'MBON' 97
DAN class == 'DAN' 340
Central complex class == 'CX' 2,950
Base union 14,574

Path term: a neuron is kept if hops(ORN → neuron) + hops(neuron → descending) ≤ 3, both by BFS on the CSR graph (A forward, A.T backward, since row = post / column = pre). That is 24,307 neurons on its own, and the union of everything is 32,498 — comfortably under the 40k cap, so central complex was not dropped. Roughly 18k of the neurons come in through the path term alone: the connector tissue between antennal lobe and descending output that nobody has a name for.

Every descending neuron in the subgraph is reachable from the receptor neurons, and a signal that enters at the nose reaches an output within two graph steps.

The dynamics, in one screen

Each neuron carries a signed rate x in [-1, 1]. One decision is four synchronous updates of the whole graph:

x_{t+1} = tanh( (1 - leak) · x_t  +  A · (gain ⊙ x_t)  +  drive )
  • A is the measured adjacency (row = post-synaptic, column = pre-synaptic), scaled by synapse counts. Measured.
  • gain is one trainable scalar per connection, initialised at 1; leak is one per neuron. Learned. These are the only parameters that train.
  • drive is the token, injected into receptor neurons (The nose). Engineered.
  • State resets to zero before every token. A stateful fly that remembers the last few coins is a later experiment.

The readout is a frozen random projection from the descending neurons' state after step four into three logits, ape, hold, sell. Frozen, so the network has to route the answer through its own wiring rather than the readout learning it.

Training

Supervised from history. Every snapshot of a token is labelled by what its price did in the next 60 minutes: pump (touched 3×), dead (closed at or below 0.3× and never saw 1.5×), otherwise meh. Pump maps to ape, dead to sell, meh to hold. Class-weighted cross-entropy, Adam, two thousand steps. The held-out split is by token and by time, so nothing the fly is scored on was seen in training.

The full 165k-neuron graph trains in about 3 GB of GPU memory; the subgraph trains on a laptop CPU in minutes.