Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

From a Fruit Fly Brain Map to an AI Model

Train a small model and test it. Then compare what it learned with a measured map of six neurons from one male fruit fly.

Run the cells from top to bottom. The fly measurements are a MaleCNS v1.0 excerpt. How they were chosen, and the CC BY 4.0 credit, are in data/README.md and under Sources.

1. Predict

The model reads two numbers, a loom signal and an odor signal. It learns three values, w_loom, w_odor, and bias. They start at 0.

Score = w_loom * loom_signal + w_odor * odor_signal + bias.

The model predicts jump only when the score is above 0. Otherwise it predicts stay.

A training example is one row: both signals, plus the correct response. Feedback is the correct response minus the prediction. The three values change only when feedback is not 0. One round is one pass through the training rows. The held-out row is kept for the test and is not used in those passes.

The first set of examples is called loom. In that set, the correct response is jump when the loom signal is above 0.

Before any training, what will the model predict for every training row?

Add your prediction here:

2. Train and test

Run the next cell. It shows the untrained predictions, trains for 8 rounds on loom, and tests the held-out row.

The controls are how you try another example set. Choose odor or either, then press Reset, Train, and Test, in that order.

If you do not see controls, edit set_name in the fallback at the bottom of the cell and run it again.

Loading...
First run: loom, 8 rounds. Check the untrained predictions against what you wrote.
Reset. Weights are loom=0, odor=0, bias=0.
Example set: loom
Untrained weights: loom=0, odor=0, bias=0
Loading...
Trained for 8 more rounds on loom with learning_rate 1
Wrong training predictions each round: [1, 1, 0, 0, 0, 0, 0, 0]
Weights after training: loom=1, odor=0, bias=0
<Figure size 1000x380 with 2 Axes>
Held-out test for loom (these rows were not used in Train)
Loading...
Held-out loom=1 odor=2 correct=jump prediction=jump

Check the untrained prediction column against what you wrote. Then look at the weights after training and the held-out row.

odor means jump when the odor signal is above 0. either means jump when at least one signal is above 0. Reset before you train a new set, or the old weights stay in place.

3. One look at the measured map

The model above did not use a fly map. Its examples and weights were written for class.

The picture below is the real excerpt: six neurons from MaleCNS v1.0, and the stronger links among them. Each number is a measured synapse count. It is not a learned weight. The full credit and the selection rule are in data/README.md.

Neurons in the excerpt: 6
Measured links in the excerpt: 16
<Figure size 720x520 with 1 Axes>
Arrows weaker than 10 synapses are in the file and are left off this picture.

4. Compare the learned weights with the measured counts

The left picture is the model after the training cell. The right picture is the measured map. The numbers are not in the same units and were not fit to each other.

Learned weights from the training cell: loom=1, odor=0, bias=0
Strongest measured synapse counts in the excerpt:
Loading...
<Figure size 1100x480 with 2 Axes>

What additional evidence would a model need before it could use a measured map like this to say how a real fly responds?

Write about evidence the class examples do not provide. The learned weights and the synapse counts are different kinds of numbers.

Add your response here:

Sources

The classroom CSV files are the filtered excerpt described in data/README.md. The perceptron, its examples, and its weights are not part of that dataset.

References
  1. Berg, S., Beckett, I. R., Costa, M., Schlegel, P., Januszewski, M., Marin, E. C., Nern, A., Preibisch, S., Qiu, W., Takemura, S., Fragniere, A. M. C., Champion, A. S., Adjavon, D.-Y., Cook, M., Gkantia, M., Hayworth, K. J., Huang, G. B., Katz, W. T., Kämpf, F., … Jefferis, G. S. X. E. (2026). Sexual dimorphism in the complete Drosophila male central nervous system connectome. Cell, 189(18), 5504-5526.e15. 10.1016/j.cell.2026.08.015