What It Means to Use a Fly’s Neural Wiring
What It Means to Use a Fly's Neural Wiring You can use a fruit fly's neural connectivity data as the structure of a neural network. When I saw demos of fly-inspired models on social media, my first reaction was: “Flies
What It Means to Use a Fly's Neural Wiring
You can use a fruit fly's neural connectivity data as the structure of a neural network. When I saw demos of fly-inspired models on social media, my first reaction was: “Flies are pretty impressive.” But what does using their wiring actually involve?
This article starts with a tiny model built from measured connections, then looks at a Rubik's Cube implementation and my Sudoku experiment. The aim is to explain what comes from the biological data, what we implement ourselves, and what the model learns.
The Python snippets are excerpts for explanation; initialization and other supporting code are omitted. My full implementation is not published.
1. What is a fly's neural wiring?
MaleCNS is a public reconstruction of the male fruit fly's central nervous system, including its brain and nerve cord. This kind of connectivity map is called a connectome.
It can tell us that neuron A connects to neuron C through 357 synapses, for example.
What data is available?
The official download page describes several kinds of data:
| Category | Contents |
|---|---|
| Annotations | Cell classifications and types, neurotransmitter predictions, and synapse-count summaries |
| Connectivity | Connections between segments, synapse locations, and synaptic partner pairs |
| Skeletons | Representations of neuron morphology |
| Volumes | Electron microscopy images and segmentation data |
For the example below, I used connectome-weights-male-cns-v1.0-minconf-0.5.feather from the Connectivity category. It is distributed as the full connection graph at the stated confidence threshold. Segments are identifiers in the reconstructed data; they should not all be assumed to represent fully identified neurons. The example uses four neurons checked against the annotations.
Turning connections into a model
Two things matter when we use this data for computation:
- Connectivity: which unit can send a signal to which other unit.
- Weights: how strongly each connection affects the computation.
Suppose the connection from A to C has 357 synapses. In this example, we divide that count by 582, the largest count among the selected connections, to obtain a weight of about 0.61. An input of 1 at A then contributes about 0.61 to C.
That is a modeling choice. The connection table does not directly specify the response “input 1 at A produces activity 0.61 at C.” We define the input units and the calculation. Synapse counts are not a direct measurement of electrical transmission strength.
2. A tiny model with “light” and “sound” inputs
Let's build a model that receives two numbers representing light and sound intensity, then identifies which is stronger. These are synthetic inputs, not readings from a camera or microphone.
We label four selected MaleCNS neurons A, B, C, and D and use these connections:
| Connection | Actual neuron IDs | Synapse count |
|---|---|---|
| A → C | 10039 → 11722 | 357 |
| A → D | 10039 → 10169 | 113 |
| B → C | 10929 → 11722 | 93 |
| B → D | 10929 → 10169 | 582 |
Source: MaleCNS v1.0, provided by HHMI Janelia FlyEM and the MaleCNS collaborators under CC BY 4.0.
We arrange the counts in a matrix, with senders as rows and receivers as columns:
synapse_counts = [
[357, 113], # A to C and D
[ 93, 582], # B to C and D
]
# Assume influence is proportional to synapse count.
# Scale the selected counts for this teaching model.
wiring = [[count / 582 for count in row] for row in synapse_counts]
Dividing by 582 preserves the ratios between these counts. It does not convert them into biological units. Actual transmission also depends on properties beyond the number of synapses.
We assign light intensity to A and sound intensity to B:
def brain(inputs):
a, b = inputs
c = max(0.0, a * wiring[0][0] + b * wiring[1][0])
d = max(0.0, a * wiring[0][1] + b * wiring[1][1])
return [c, d]
With light alone, C is approximately 0.61 and D is 0.19. With sound alone, C is approximately 0.16 and D is 1.0. The two inputs produce different activity patterns.
These neurons were selected for a useful teaching example, not because they form a verified light-and-sound processing circuit. The input assignments are artificial, and other connections are omitted.
Learning a readout
The activity values do not come with labels saying “light” or “sound.” We add a readout that converts them into scores:
def readout(activity):
c, d = activity
light_score = c * weights[0][0] + d * weights[1][0] + bias[0]
sound_score = c * weights[0][1] + d * weights[1][1] + bias[1]
return [light_score, sound_score]
wiring contains the fixed weights derived from fly data. weights and bias belong to the readout and are learned from examples.
When the prediction is wrong, we adjust the readout to raise the correct answer's score and lower the selected wrong answer's score:
for i in range(2):
weights[i][correct] += activity[i]
weights[i][chosen] -= activity[i]
bias[correct] += 1.0
bias[chosen] -= 1.0
This is a perceptron learning rule, not backpropagation. After training on four input-label pairs, the model produces:
| Input [light, sound] | Activity [C, D] | Prediction |
|---|---|---|
| [1.0, 0.0] | [0.61, 0.19] | Light |
| [0.0, 1.0] | [0.16, 1.00] | Sound |
| [0.8, 0.2] | [0.52, 0.36] | Light |
| [0.2, 0.8] | [0.25, 0.84] | Sound |
The last two inputs were not used during training. This is a small demonstration, not a broad generalization test.
What comes from the fly here is just the four measured connections and their counts. That is less dramatic than “running a fly brain” might suggest. Let's look at a larger example.
3. The Rubik's Cube example
FlyCube is a public implementation using an 8,192-neuron subgraph extracted from MaleCNS. It predicts scores for possible moves and a value estimate for the cube state. I am treating it as a reference implementation; I have not established that it is the project shown in the social-media demo.
Cube state
→ Learned input encoder
→ Activity updates through fly-derived wiring
→ Learned readout
→ Move scores and a state-value estimate
The input is an encoding of the colors of 54 stickers, not an image. The input encoder converts it into signals for the circuit. The model repeatedly updates continuous activity values while retaining some of the previous activity. It does not simulate individual spikes. See the project's architecture and methodology.
Training uses solutions supplied by existing solvers and exact search for shallow states. At inference time, the teacher solver is not called. One mode selects moves from the model's scores; another uses the learned scores and value estimates to guide a bounded search.
The readout therefore learns to choose actions from the circuit's activity. Training on solver-generated answers is different from querying that solver while playing.
There is an important qualification: the published results were obtained with an older implementation that propagated connectivity in the reverse direction. The code has been corrected, but results from training with the corrected direction have not yet been reported in the project's documentation. The reported model solves some shallow scrambles but solves none of the 100 uniformly sampled legal states under the stated budgets. Its comparisons with rewired circuits are also results from the older implementation, on one task and scale. These conditions are documented in the project's limitations.
4. My Sudoku implementation
My Sudoku implementation also feeds a board into a fly-derived circuit and reads out the next action:
Board, previous action, and referee response
→ Fixed numerical encoding
→ Input to a circuit with fly-derived wiring
→ Membrane-potential and spike updates
→ Activity features
→ Readout selects the next action
Each cell is encoded using ten positions: empty and digits 1–9. For example:
# Simplified encoding for one cell.
digit = 3
cell_signal = [0.0] * 10
cell_signal[digit] = 1.0
# [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
These signals are assigned to predetermined neurons. The circuit uses a leaky integrate-and-fire (LIF) model: inputs change a unit's membrane potential, and crossing a threshold produces a spike that is transmitted along its connections. The connectivity comes from measured data; the dynamics are a chosen approximation.
For a 9×9 board, the readout receives 1,024 features derived from activity, including measurements from input populations and aggregates across the circuit. After standardization, a linear readout produces action scores:
scores = standardized @ weights + bias
chosen = int(scores.argmax())
weights has shape (1024, 811). The 811 actions are:
- 729 placements: 81 cells × 9 digits.
- 81 erase actions.
- One wait action.
A referee rejects actions such as changing a given cell or introducing duplicate digits. It does not choose a correct alternative. The model receives the response and selects its next action.
The readout is trained on teacher action examples. Its coefficient-sharing scheme also incorporates row, column, and box symmetries, so the design includes task-specific assumptions.
The retained model completed five of eight puzzles used repeatedly for model selection. Those eight puzzles are not an independent final test, so 5/8 should not be interpreted as its success rate on unseen Sudoku in general.
Limited computing resources or shortcomings in my model design may have played a part, but I have not established why it failed on the remaining puzzles.
Compared with FlyCube, this implementation has a fixed input assignment and spiking dynamics. Training mainly targets the readout on extracted features rather than backpropagating through the entire circuit.
5. How RRN represents Sudoku
Recurrent Relational Networks (RRN) provide another approach. Each cell has an internal state, and cells in the same row, column, or 3×3 box are connected.
An internal state is an array of numbers retained between updates. For illustration, suppose each cell has four values:
states = [
[0.2, -0.5, 0.8, 0.1], # Cell 0
[0.3, 0.1, 0.2, 0.7], # Cell 1
# ...81 cells in total
]
That would be an 81×4 matrix. The actual model uses a larger state.
Each cell receives its digit and row/column position as input. During each update, messages computed from connected cells' states are combined with the cell's previous state and input. “Exchanging information” means using numerical data from one cell to update another cell's state.
For example, a blank cell can receive information from a cell containing 7 in the same row. The model learns how to use such messages to predict digits; it is not given a hand-written procedure saying “remove 7 from this cell's candidates.”
Training uses puzzle-solution pairs and backpropagation through the repeated updates. The authors report solving 96.6% of their difficult 17-given Sudoku evaluation set. That is a result on a particular benchmark, not a guarantee of solving every Sudoku. See the paper and public code.
RRN builds Sudoku relationships into its connectivity. A fly-derived circuit gets its connectivity from biological reconstruction. Both can retain state and exchange information, but the relationships represented by their connections are different.
6. What to take away
In these examples, using fly wiring means incorporating measured connections and synapse counts into a computational model. Input encoding, activity dynamics, and the mapping from activity to answers still need to be designed.
The tiny light-and-sound example learns a readout over four connections. FlyCube uses a larger subgraph with learned input and output components. My Sudoku experiment uses fixed input assignments, spiking dynamics, and an action readout.
I have not demonstrated an advantage from using fly wiring in my Sudoku experiment. I also have not made a controlled comparison that establishes whether a task-specific RRN is more efficient.
The distinction that matters is between using biological connectivity and showing that it improves the result. The demos are fun to watch, but understanding their input, training, search, and evaluation makes it much clearer what they actually do.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.