Deep Learning A to Z · Fruit Fly Special 1

How does a fruit fly smell, see, and recognize?

Even inside a fruit fly's head, no bigger than a speck, signals travel along set paths. The antennae and compound eyes turn the world into electrical signals, the nerves sort and carry those signals, and the brain recognizes "that's food" or "that's danger." And the rules behind those judgments weren't handed down by anyone — they were learned from experience. Follow this path, and you'll naturally see how artificial neural networks grow from an ultra-simple model into multilayer deep learning.

~140,000neurons in the whole brain [1]
~50 millionsynapses (connections) [1]
~800ommatidia per compound eye = pixels [2]
~50 typesof olfactory receptor neurons [3]
~2,000Kenyon cells per mushroom body [4]
~86 billionfor comparison: neurons in the human brain [5]

Why learn neural networks from a fruit fly?

The human brain is too big, and computer neural networks are too abstract. The fruit fly is just the right size in between. You can take in the whole path from sense organs to behavior at a glance, and you can actually switch individual neurons along that path on and off in experiments.

Reason 1Its full wiring diagram is public

In 2024, a wiring diagram (connectome) of every neuron and connection in the fruit fly brain was completed. In neural-network terms, it's like being able to see a model's entire architecture and connections.

Reason 2Input to output is short and clear

Smelling something and approaching it, seeing a looming shadow and taking off. The path of senses → nerves → brain → behavior is short, so it's easy to follow step by step.

Reason 3You can switch specific neurons on and off

Genetic tools can stop specific neurons from working. It's like deleting one unit from a neural network and seeing how its performance changes.

Why does every sense become an electrical signal?

Light is photons, smell is molecules, sound is vibrations in the air, and taste is substances dissolved in water. They're all different kinds of stimuli, yet by the time they reach the brain they all have the same form: changes in the voltage across a neuron's membrane, and electrical pulses (spikes).

Light → compound eye

Photoreceptor

Light changes the shape of a molecule, and that change opens ion channels that alter the cell's voltage.

Image pixel values
Odor molecules → antenna

Olfactory receptor neuron

When odor molecules bind to receptors, ions flow in and out and the voltage rises; once it crosses a threshold, the neuron fires a spike.

Sensor readings
Wind & sound → antenna

Johnston's organ

When the tip of the antenna vibrates, the mechanosensory neurons inside are stretched and produce electrical signals.

Sound waveform numbers
Taste → legs & mouth

Taste neuron

Fruit flies taste with their legs too. When sugar or a bitter substance touches them, taste neurons send out electrical signals.

Another input channel
Stimulus→ Receptor · voltage change→ Axon · pulse travels→ Synapse · crosses as chemicals→ Next neuron · electric again
Sense
Stimulus strength
Synapse strength (weight)

Why electricity? Five reasons

  1. A common language: light, smell, sound and taste all have to be converted into the same form so the brain can mix and compare them in one place. It's the same reason deep learning turns photos, text and sound into lists of numbers.
  2. It's fast: at the speed odor molecules drift and spread through the body, you could never dodge a fly swatter. Electrical signals carried by flows of ions travel from the tip of the body to the brain in an instant.
  3. It doesn't fade over distance: a spike is regenerated again and again as it travels along the axon, so its size doesn't shrink even over a long path.
  4. Strength is expressed as "how many times": every spike is the same size; a stronger stimulus just makes the neuron fire more often. Conveying strength by count rather than size makes it robust to noise. This firing rate corresponds to an artificial neuron's "output number."
  5. Strength can be adjusted at the synapse: in the gap between two neurons, electricity is converted into chemicals (neurotransmitters) that cross over. How much gets transmitted, and how effectively, is exactly the weight — and learning means changing this transmission efficiency.

There are exceptions. Neurons that send signals only a short distance, like the photoreceptors in the compound eye, transmit by raising and lowering their voltage continuously instead of spiking. Pick "Light" to see the difference.

Rotate the fruit fly brain and follow the signal's path

Each brain region is drawn as dots, like a fluorescently stained microscope image. Pink dots are nerve tissue, red dots are sense organs, and the green glow is a signal flowing right now. This is a schematic model, not real anatomical data. The front-back and left-right relationships between regions are correct, but sizes and shapes are simplified.

Signal path
Speed1.0×

Region info · click the brain or a button below

Sense organs → nerves → brain → behavior is input → hidden layers → output

The fruit fly's four stages map one-to-one onto the basic structure of a neural network. Every model in the ladder below is a story of adding layers within this framework.

1 · Sense organs

Turn the world into numbers

Olfactory receptor neurons in the antennae respond to odor molecules, and the ommatidia of the compound eye respond to light. The strength of the response is the number.

Neural network: input layer (data)
2 · Nerves (relay & sorting)

Select and refine the numbers

The antennal lobe and lamina gather incoming signals, balance their strength, and convert them into handy forms such as getting brighter or darker.

Neural network: preprocessing · first layer
3 · Brain (recognition)

Recognize patterns

The mushroom body, lateral horn and lobula extract meanings like "this smell is food" or "this shadow is an approaching predator."

Neural network: hidden layers (features · patterns)
4 · Behavior

Pick one

Approach, avoid, or take off? The scores of several signals are compared, and one behavior wins.

Neural network: output layer (decision)

Are the rules given, or are they learned?

There are two ways to get a computer to do a job. A person can write out the rules one by one (rule-based), or you can give it only examples and outcomes and let it find the rules on its own (learning-based). Deep learning is the second way, and the fruit fly brain contains both.

Rule-based (Rule base)

Someone writes the rules in advance

If fruit scent > 0.5 → approach
If carbon dioxide > 0.3 → avoid
Otherwise → stay still

The rules are visible, so they're easy to understand. But you have to know every possible situation in advance, and when the environment changes, whoever wrote the rules has to fix them by hand. In a situation the rules don't cover, it's helpless.

In the fruit fly: the innate responses of the lateral horn. Evolution wrote these rules, and a single fly can never change them in its lifetime.

Learning-based (Learning)

It looks at outcomes and fixes its own rules

1. Predict with the current values and act
2. See the actual outcome (food +1, electric shock −1)
3. value ← value + η × (outcome − prediction)

No rules are written directly. Instead, the weights are adjusted by "how wrong the prediction was." Repeat this, and the rules appear inside the weights on their own. If the environment changes, it simply learns again.

In the fruit fly: the mushroom body. When punishment or reward arrives, dopamine neurons send a signal that changes the Kenyon cell → output neuron connections. Whether this signal actually computes a prediction error like "outcome − prediction" is still being researched; here we simplify it to a prediction-error rule to make it easier to understand.

Two flies born with the same preferences — what happens when the world changes?

Both flies start out liking fruit scent A. But in this room, there's an electric shock on the A side and sugar on the B side. The fly on the left only follows its rules; the fly on the right learns from outcomes. Use "Change environment" to switch which side is dangerous.

Learning rate η
Speed

Where are learned rules written?

The right-hand fly's "rules" aren't written down as sentences anywhere. All there is are two approach values — that is, two weights. Deep learning models are exactly the same. Millions or billions of weights are the rules, so they perform well, but it's hard to pull out "why it decided that" in human words. Rule-based systems are easy to explain; learning-based systems are easy to adapt. The fruit fly uses both: it gets by on innate rules in unfamiliar situations, and corrects them with learned rules as experience builds up.

The model ladder — climb four rungs in order

With each rung, one more ability seen in the fruit fly is added. On each rung you'll operate the model yourself, run into a problem it can't solve, and then move up to the next rung.

1Ultra-simple

One input, one connection — smell carbon dioxide, avoid it

Model: y = w × xFruit fly: CO₂ avoidance

In the fruit fly

The fruit fly's antennae have dedicated sensory neurons that detect only carbon dioxide. Their signals converge on a single glomerulus in the antennal lobe, and the fly avoids carbon dioxide without having to learn it. Here we boil this path down to "one sensor → one connection → behavior."

In a neural network

This is the smallest possible model: it outputs 1 if the input x multiplied by the weight w exceeds the threshold θ, and 0 otherwise. The weight means "how loudly should I listen to this input," and the threshold means "how easily should I react."

CO₂ concentration x
Connection strength w
Threshold θ

Explained for beginners

In this model, "learning" means setting w and θ to the right values. The fruit fly is born with these values already tuned by evolution. Make w large and it flees even faint carbon dioxide; make it small and the CO₂ has to be strong before it flees.

Its limits are clear, too. This model looks at exactly one input. It can't solve the problems a fruit fly actually faces — ones that require weighing several signals together, like "There's a fruit scent and a vinegar scent at the same time. Is this worth eating?" So we add more inputs.

2Simple

One neuron weighing several inputs — the perceptron

Model: y = σ(w₁x₁ + w₂x₂ + b)Fruit fly: judging food odors

In the fruit fly

Ripe fruit gives off both a fruity scent (esters) and a vinegar scent (acetic acid). Suppose one neuron receives signals from two glomeruli and judges "is this the smell of food?" It gives the two signals different weights, adds them up, and then decides.

In a neural network

Multiply each of several inputs by its weight, add them up, add a bias b, then use the sigmoid σ to turn the result into a probability between 0 and 1. The only boundary this model can draw is a single straight line on the plane at right.

Edible odor (label 1)Not edible (label 0)Model's boundary✕ Misclassified odor● Filled dot = training data (used for learning)○ Hollow dot = validation data (not used for learning; for scoring)
Problem
Learning rate η

See it as behavior — a fruit fly choosing among never-before-smelled odor cups (validation data) using the current model

What does "learning" actually do? Four steps

  1. Predict: compute the score for one odor with the current w₁, w₂, b.
  2. Error: measure the difference between the correct answer (food 1, not food 0) and the predicted probability.
  3. Assign blame: multiply the error by each input's size to find how much each weight contributed to the mistake.
  4. Fix: nudge each weight a little (by the learning rate η) in the opposite direction. Repeat this for every odor.

Pick the "Hard" problem and train. Real fruit flies approach faint vinegar odors but avoid ones that are too strong. That makes the food region a band between two lines, and a single line can't cut out a band. No matter how long you train, accuracy stalls at some level. That's why we need the next rung.

3Standard

One hidden layer — antennal lobe → mushroom body → output neuron

Model: 2 inputs → H hidden → 1 outputFruit fly: mushroom body circuit

In the fruit fly

Signals from the antennal lobe fan out to thousands of Kenyon cells in the mushroom body. Each Kenyon cell picks up input from a few glomeruli and responds to its own "odor combination." Output neurons gather those responses and decide whether to approach or avoid. Learning happens mainly at the Kenyon cell → output neuron connections.

In a neural network

Insert a "hidden layer" between the input and the output. Each hidden neuron draws one line on the plane, and by combining those lines the output neuron can build boundaries that bend or form bands. This is the multilayer perceptron (MLP).

Odor input→ Hidden layer (forward pass)→ Output · error→ Pass blame back (backpropagation)→ Update weights
Data
Training method
Hidden neurons H
Learning rate

See it as behavior — true skill on never-before-smelled odor cups (validation data)

Memorizing vs. understanding — training data and validation data

A student who saw the exam questions in advance can score 100 on that exam and still prove nothing about their real ability. Models are the same. So we split the data in two. We adjust the weights using only the training data (filled dots), and grade with validation data (hollow dots) that was never used for learning. The validation score is the true measure of skill.

  1. Underfitting: even the training score is low. The model is too simple. The hard problem on rung ② is an example.
  2. Just right: training and validation scores are both high and close to each other.
  3. Overfitting: the training score is high but the validation score is low. With too little data, or wrong labels mixed in, the model memorizes individual examples instead of the rule. Pick "Little, noisy data" to see for yourself.

Common ways to prevent overfitting are adding more data, stopping training when the validation loss starts rising again (early stopping), and not making the model bigger than it needs to be. Fruit flies face a similar problem: so that they don't over-generalize from a single chance experience, long-lasting memories form only after repeated training. In real deep learning, besides validation data, people often set aside separate test data that is used only once, at the very end.

Backpropagation in plain words

It's a calculation that takes the error at the output and divides it backward according to "who's to blame." Hidden neurons that are strongly connected to the output neuron, and that were strongly active at the time, take more of the blame. Once blame is assigned, everything — right down to the input → hidden connections — is corrected at once.

Fruit flies don't do this backward division. The connections into the Kenyon cells are set almost at random and don't change; dopamine adjusts only the last connections (Kenyon cell → output neuron). Choose "Fly-style model" and you'll see it struggles with few hidden neurons, but once you raise the count to 30–60, random lines alone are enough to cut out the band. It hints at why the fruit fly keeps as many as ~2,000 Kenyon cells.

4Multilayer

A visual path with stacked layers — seeing a looming shadow and escaping

Model: layer upon layer, like a CNNFruit fly: compound eye → lamina → medulla → lobula → giant fiber

In the fruit fly

When a fly swatter approaches, a fruit fly takes off in an instant. The ommatidia of the compound eye measure brightness, the lamina splits signals into brightening and darkening, T4 and T5 neurons in the medulla and lobula plate compute the direction of motion, and LPLC2 neurons in the lobula detect "motion spreading outward in all directions" — that is, an approaching object. This signal passes through the giant fiber neuron and becomes a jump.

In a neural network

It's built just like a convolutional neural network (CNN). Each layer repeats the same calculation over a small area at every position (weight sharing), and as you go up the layers the field of view widens and the features become more complex: brightness → change in brightness → direction of motion → looming. Each layer on its own is simple, but stacked together they make a hard judgment.

Compound eye · brightness→ Lamina · brighter/darker→ Medulla · lobula plate · motion direction→ Lobula · looming detection→ Giant fiber · jump
Object to show
View angle
Speed

This is a computational model simplified for explanation. The ommatidia are reduced from about 800 to 169, and the direction of motion is computed directly from the speed of the object's edges. Real T4 and T5 neurons work out direction by comparing signals from neighboring ommatidia with a time delay.

Why stack multiple layers?

It's hard to write a rule that detects an "approaching object" straight from the brightness values of the ommatidia in one step. The object might be dark or bright, on the right or on the left. Instead, we break the problem into easy pieces and give one to each layer.

  1. Layer 1 (lamina): did this ommatidium just get darker, or brighter?
  2. Layer 2 (medulla · lobula plate): compared with neighboring ommatidia, which way is the edge moving?
  3. Layer 3 (lobula): is there outward motion in all four directions — up, down, left and right?
  4. Output (giant fiber): if so, take off now.

With an "object passing by," one edge moves outward while the opposite edge moves inward, so it doesn't satisfy all four directions. That's why the fly doesn't jump even if the object is large and fast. A CNN that recognizes a cat in a photo stacks its layers the same way: lines → edges → parts → whole shape.

Comparing model architectures — this page's models vs. MLP · RNN · GRU · LSTM · CNN

Press the buttons to switch between diagrams of six architectures. Green lines are learned connections, dashed lines are fixed connections, and orange arrows are memory carried across time. All diagrams are schematics showing the principle.

Six architectures at a glance

Learned connections / total connections (input 16×16, 3 classes)

Gray bar = all connections, colored bar = learned connections. Deep learning models learn everything, while most connections in the fruit fly model are fixed. The Trainer below and Code 2 in Common section A count the same numbers.

Level of evidence in the last row: Real circuit · measured the model transcribes a real circuit · Similar structure the wiring looks alike, but this is not evidence they compute the same thing · Loose analogy · Pure analogy just a figure of speech to aid explanation, no biological basis.

Key differences from this page's point of view

The ladder on page ① (ultra-simple → multilayer) was the MLP and CNN side of the story. Alongside it, the fly-style model offers a different answer: "even without training the hidden layer, making it wide and sparse works quite well." In machine learning, random features, extreme learning machines (ELM) and reservoir computing share the same idea. The fruit fly brain also has circuits that handle time, like RNNs and LSTMs (the central complex), but the models on this page make one-shot judgments.

Fruit Fly Trainer — "teach, learn, decide" with example drawings

Like Teachable Machine, we walk through an example of ① collecting example drawings for each class, ② training, and ③ checking with drawings the model has never seen. On the same drawing data, we trained the fly-style model (only the output layer learns) and a deep learning MLP (all layers learn) side by side. The drawings are 16×16 images jittered to look hand-drawn.

① Collect examples
Food · circle · 8 of the 24 training drawings
Danger · X · 8 of the 24 training drawings
Path · horizontal line · 8 of the 24 training drawings

We made 30 drawings per class: 24 for training and 6 (18 in total) for validation. The validation drawings are never shown during training.

② Train (30 epochs)
0%50%100%1102030EpochComputed values (fixed seed)

Green = fly-style model · Blue = MLP · dashed = training accuracy, solid = validation accuracy

83%Fly-style model validation accuracy (training 100%)
89%MLP (32 hidden) validation accuracy (training 100%)
3,003learned connections in the fly-style model (of 13,003 total)
8,323learned connections in the MLP (32 hidden) — all of them. The MLP in the architecture comparison section has 64 hidden neurons
③ Decide on never-before-seen drawings
Test drawing
Fly-style model · 18 validation
CircleXLine
Circle420
X060
Line015
MLP · 18 validation
CircleXLine
Circle420
X060
Line006

What to take away from this example

Both models got 100% of the training drawings right, but on the validation drawings the fly-style model scored 83% and the MLP 89%. This difference (the gap between training and validation) is the degree of overfitting. Even though the fly-style model has only about 36% as many learned connections as the MLP, its validation accuracy doesn't lag far behind. Both models mistook 2 of the 6 validation circles for X's (see the confusion matrix below). With only 24 training drawings per class, mistakes like this happen. To try it with your own drawings, run Code 2 in Common section A in Colab.

What it shares with Teachable Machine

The flow is the same: make classes → collect examples → train → judge new inputs.

How it differs

Teachable Machine trains only a small classifier on top of features already learned by a large image model (MobileNet) — this is transfer learning. In this example, two models learn 16×16 drawings from scratch. That makes it well suited to simple shapes, but not to complex inputs like photos.

One-page summary — the four-rung ladder

The higher the rung, the more connections the model has, the more complex the boundaries it can draw, and the deeper the meaning it can extract. The fruit fly's senses → nerves → brain → behavior hold all of these stages in a single body.

RungModel structureFruit fly exampleNew abilityRemaining limit
① Ultra-simple1 input → 1 output
y = threshold(w·x)
Carbon dioxide → avoidReacts when the signal is strongSees only one input
② SimpleSeveral inputs → 1 neuron
Perceptron
Fruit scent + vinegar scent → is it food?Weighs several signals, learns from errorsOnly one straight boundary line
③ StandardInput → hidden layer → output
Multilayer perceptron
Antennal lobe → mushroom body → output neuronCurved and band-shaped boundaries, recognizing combinationsLarge, complex inputs need a huge number of hidden neurons
④ Many layersStacks many layers
like a convolutional neural network
Compound eye → lamina → medulla → lobula → giant fiberBuilds up simple features to recognize meanings like "approaching"The deeper the network, the more data and computation training takes
Weight

Synapse strength

A value changed by learning. Inhibitory synapses are negative weights.

Activation function

Fire or stay quiet

A signal is sent only when the threshold is crossed. This bend is what makes stacking layers meaningful.

Error signal

Dopamine (punishment/reward)

Tells what went wrong. The fruit fly doesn't pass it back through the layers; it delivers it directly to specific connections.

The whole model

Connectome

The wiring diagram of the entire brain. Who connects to whom, and how strongly, is the model's structure.

Limits of the analogy. Real neurons exchange signals as electrical pulses, and the same connection can behave differently depending on timing and the body's state. The 3D brain and computational models on this page are heavily simplified to show the principles. Deep learning did not copy the brain; it borrowed a skeleton: "layers, connection strengths, thresholds, and fixing by error."

Third page: a project that runs an entire real fruit fly wiring diagram to move a Minecraft mob, compared with the previous two pages. A Fruit Fly Brain in Minecraft — a nervous system driven by its wiring diagram alone.

Colab code — run this page yourself

Both programs use only libraries preinstalled in Colab. Click "Download notebook (.ipynb)" and open it in Colab with File → Upload notebook, or copy the code and paste it into a new notebook cell.

Code 1 · The fly-style model in NumPy — fixed random expansion + train only the output layerLinked to section ③ Fly-style model and "Hands-on: comparing structures" · numpy · under 1 s on CPU

Builds fixed connections for 1,000 Kenyon cells and, on top of a sparse code where only the top 8% are switched on, trains just one output layer with the delta rule. To use your own data, replace X (samples × 256) and Y (label indices).

Output (run on 2026-10-04, numpy 2.4 · CPU). The random seed is fixed, so it's the same every time you run it.
Code 2 · Five standard deep-learning models vs. three fruit fly models in PyTorchLinked to "Hands-on: comparing structures · Trainer" · torch, numpy, matplotlib · about 1 min on CPU

Trains MLP, CNN, RNN, GRU, LSTM and three fruit fly models on the same drawing data with the same split, then compares connection counts and accuracy. It runs the "Trainer example" calculation yourself on a larger dataset (4 classes, 160 images).

Output (run on 2026-10-04, PyTorch 2 · numpy 2.4 · CPU). Trained separately with two seeds. The fruit fly models' fixed connections use a set seed, so both seeds give the same result. Numbers may vary with seed, version and hardware.

How it differs from standard deep-learning code

ItemCode 1 (fly-style)Standard deep-learning code
What gets trainedJust the output layer (3,000)All layers (16,643)
Gradient computationNot needed: error × inputloss.backward() computes it layer by layer via the chain rule
Hidden representationRandomly fixed at birthLearned to fit the data
Hidden layer shapeWide and sparse (only 8% of 1,000 active)Narrow and dense (all 64 have values)
Key lineW_out += lr * np.outer(y − p, k)opt.step()
Tools neededNumPy onlyPyTorch (autograd)
Name in machine learningRandom features, extreme learning machine, reservoir computingMultilayer perceptron (MLP)
View standard deep-learning code for comparison (mlp_backprop.py, PyTorch)

AI prompts — use this code as a starting point

Prompts to paste into an AI assistant such as ChatGPT, Qwen or Claude. Clicking "Copy" appends the code you choose after the prompt. Replace the parts in 〔 〕 with your own situation.

Code to attach

An AI's answer is only a starting point. Always check any suggested papers, numbers and library functions against the original sources and official documentation. If you used AI help for a competition entry or paper, disclose that you did and to what extent, following the rules of the organizers and the journal.

Glossary

This is the same dictionary as the yellow dotted underlines in the text. Hover over or tap an underline to see the same explanation.

Analogies — and where they break down

Analogies are a first step toward understanding, but they can also plant misconceptions. Fruit fly/brain analogies are marked by strength: Direct evidence that it really does the same thing · Partial only some properties are similar · None no known counterpart

ConceptEveryday analogyFruit fly/brain analogyWhere the analogy breaks down
PerceptronScoring several people's opinions, adding them up, and deciding once the total passes a barPartial A neuron gathers inputs and fires when they cross a thresholdIn a real neuron, inputs build up and leak away over time. A perceptron has no time (see leaky integrate-and-fire in Special 3)
Hidden layerA company's middle managers: they gather reports from the floor and pass a summary up to the CEOPartial Kenyon cells in the mushroom body re-represent odor signals broadlyKenyon cells' input connections are set randomly and are not learned. Hidden layers in deep learning are learned
Weight learningWriting missed problems in a mistake notebook and fixing them next timeDirect Dopamine changes the strength of mushroom body output connections, pairing odors with outcomesWhether the fruit fly's dopamine signal computes a "prediction error" is still being studied. The learning rule in this special is simplified for explanation
BackpropagationWhen the result is bad, assigning blame backward from the end of the production lineNoneThere is no known evidence that the brain passes exact gradients backward layer by layer
Multilayer visual pathwayA factory assembly line: each stage builds slightly more complex partsPartial Going from compound eye → lamina → medulla → lobula, increasingly complex motion is detectedThe filters in ④ were set by hand for explanation. A CNN learns its filters
Turning input into numbersExchanging every country's money into a single currencyDirect Sensory neurons turn light, smell and taste into electrical signalsReal signals are the rate and timing of spikes. The firing-rate numbers in this special are example values

About the author and references

E-1 About the author · E-2 Academic references · E-3 Figure sources

E-1 About the author

Sangsun Ahn (CEO of M-Robo Inc.)

After working at the Korea Electrical Safety Corporation and the Maeil Business Newspaper, he founded M-Robo Inc., a spin-off venture of Maeil Business Newspaper, where he now serves as CEO. M-Robo began as an in-house venture of a news company and grew into a media venture: it provided a robot reporter (Stockbot) for the Kukmin Ilbo and has carried out many projects for the Korea Internet & Security Agency, the Korea Press Foundation, the Korea Communications Agency and others. It now runs its own AI news service, Money-Robo. As CEO, he won the Asia Open Data Hackathon and twice received the Minister of the Interior and Safety Award for contributions to data entrepreneurship, and he is the inventor and registrant of five patents in artificial intelligence and blockchain. He is the author of "AI Crime and Self-Defense" (in Korean), and has developed e-learning content on fintech, statistics and artificial intelligence for the Online Lifelong Education Institute of KOREATECH (Korea University of Technology and Education). He holds a PhD in economics (Dongguk University, mathematical microeconomics). He teaches courses on data and artificial intelligence at several universities, including Kookmin University and Hoseo University. Full profile

Courses

  • Sangsun Ahn (2025). "Data Science for Business" lecture notes (in Korean). Department of AI Convergence, Open Cyber University of Korea.
  • Sangsun Ahn (2025). [K-Digital] Artificial Intelligence: Natural Language Processing (in Korean). STEP (Smart Training Education Platform), Online Lifelong Education Institute, KOREATECH.
  • Sangsun Ahn (2024). [K-Digital] Fundamentals of Fintech Data Analysis (in Korean). STEP (Smart Training Education Platform), Online Lifelong Education Institute, KOREATECH.

Go to the STEP courses: link.step.or.kr/1qyVoJ · link.step.or.kr/M9na9N · link.step.or.kr/brqEyc
If the links don't work because of a site redesign, please go to www.step.or.kr.

Papers and presentations

  • Sangsun Ahn (2025). A study on household expenditure prediction models using the Korean Retirement and Income Study panel data: An AI model-based approach (in Korean). Future Society, 16(2). Full text
  • Sangsun Ahn (2025). A study on household expenditure prediction models using the Korean Retirement and Income Study panel data: An AI approach (in Korean). Presentation at the KReIS Conference (2025.05.13), National Pension Research Institute, National Pension Service. Slides
  • Sangsun Ahn (2025). A study on an algorithm for detecting suspected drug transactions from SNS text: Focusing on pattern and context analysis (in Korean). Future Society, 16(1). Full text
  • Sangsun Ahn (2024). Statistics-based countermeasures against adversarial data for securing anomaly detection models in finance: Empirical analysis and simulation results (in Korean). Future Society, 15(3). Full text
  • Sangsun Ahn (2024). An AI-based solution for detecting SNS posts based on virtual character traits (in Korean). Poster at the 2024 Summer Newmedia Party (2024.06.19), Seoul Media Institute of Technology.
  • Sangsun Ahn (2024). Machine learning models using industrial accident panel data (in Korean). Poster at the 10th Panel Study of Workers' Compensation Insurance Conference (2024.05.17), Labor Welfare Research Institute, Korea Workers' Compensation & Welfare Service.
  • Sangsun Ahn (2024). Analysis and forecasting of virtual asset time-series data: Comparing time-series and AI models and suggesting improvements (in Korean). Future Society, 15(1). Full text

E-2 Academic references

  1. [R1] Dorkenwald, S., Matsliah, A., Sterling, A. R., … Murthy, M. (2024). Neuronal wiring diagram of an adult brain. Nature, 634, 124–138. doi:10.1038/s41586-024-07558-y — Hero [1], section "3D brain"
  2. [R2] Aso, Y., Hattori, D., Yu, Y., … Rubin, G. M. (2014). The neuronal architecture of the mushroom body provides a logic for associative learning. eLife, 3, e04577. doi:10.7554/eLife.04577 — Hero [4], section ③
  3. [R3] Azevedo, F. A. C., Carvalho, L. R. B., Grinberg, L. T., … Herculano-Houzel, S. (2009). Equal numbers of neuronal and nonneuronal cells make the human brain an isometrically scaled-up primate brain. Journal of Comparative Neurology, 513(5), 532–541. doi:10.1002/cne.21974 — Hero [5]
  4. [R4] Suh, G. S. B., Wong, A. M., Hergarden, A. C., … Anderson, D. J. (2004). A single population of olfactory sensory neurons mediates an innate avoidance behaviour in Drosophila. Nature, 431, 854–859. doi:10.1038/nature02980 — Section ① (carbon dioxide avoidance)
  5. [R5] Maisak, M. S., Haag, J., Ammer, G., … Borst, A. (2013). A directional tuning map of Drosophila elementary motion detectors. Nature, 500, 212–216. doi:10.1038/nature12320 — Section ④ (T4·T5)
  6. [R6] Klapoetke, N. C., Nern, A., Peek, M. Y., … Card, G. M. (2017). Ultra-selective looming detection from radial motion opponency. Nature, 551, 237–241. doi:10.1038/nature24626 — Section ④ (LPLC2 looming detection)

Footnotes [1]– in the text: sources of numbers and facts

No.ContentValueSource
[1]Total neurons and synapses in the fruit fly brainAbout 140,000; about 50 millionFlyWire Consortium (2024) Nature — whole-brain connectome of the adult fly
[2]Ommatidia per compound eyeAbout 750–800Textbook value for the fruit fly visual system (varies by individual and strain)
[3]Types of olfactory receptor neurons / glomeruli in the antennal lobeAbout 50 types / about 50Typical values from fruit fly olfaction research (e.g., Couto et al. 2005, Curr Biol)
[4]Kenyon cells per mushroom body; types of output neuronsAbout 2,000 / 21 typesAso et al. (2014) eLife — anatomy of the mushroom body circuit
[5]Neurons in the human brainAbout 86 billionAzevedo et al. (2009) J Comp Neurol
[6]Carbon dioxide avoidance; attraction/avoidance depending on vinegar concentration—Suh et al. (2004) Nature · Semmelhack & Wang (2009) Nature
[7]T4·T5 motion-direction detection; LPLC2 looming detection—Maisak et al. (2013) Nature · Klapoetke et al. (2017) Nature

E-3 Figure sources

  • The hero numbers [2] and [3] are textbook values for the fruit fly visual and olfactory systems (they vary by individual and strain). Detailed sources are in the table below
  • Character art in the closing scene: Deep Learning A to Z lab characters

TIPs for educators

A guide for instructors, on-the-job training (OJT) leads and tutors. Times are estimates; adjust them to your actual class.

AudienceCollege students and working adults new to deep learning. No biology background needed
PrerequisitesAddition, multiplication and reading graphs. Python is needed only for the Colab exercises
Learning goals① Map senses → nerves → brain → behavior onto input → hidden layer → output ② Explain why a perceptron can't solve the band-shaped problem and why a hidden layer can ③ Spot overfitting by comparing training and validation scores
Estimated timeReading 50–60 min · animation demos 25 min · Colab exercises 30 min (Code 1: 10 min; Code 2: 2 min to run + 15 min to interpret)

Three lesson plans

Lecture, 50 min

Concept-focused

Intro 5 min (why fruit flies) → senses→nerves→brain mapping table 10 min → rules vs. learning 10 min → ①②③ ladder 20 min → check questions 5 min.

Workplace OJT, 90 min

Focused on applying it at work

Rules vs. learning playground 20 min (compare with rule-based systems at work) → ②③ overfitting 20 min → reading the confusion matrix with the Trainer example 20 min → running and interpreting Code 2 30 min.

1:1 tutoring

Pace by level

Beginners: only "Rules vs. learning" and ①②. Intermediate learners change the number of hidden neurons in ③ to create overfitting themselves, and compare the number of trained connections (3,003) in Code 1 and the Trainer example.

Tips by section

SectionQuestion to pause and askHands-on tip
Why fruit flies"Is 140,000 neurons a lot or a little?"Compare with the human brain's 86 billion
Electrical signals"Why do smell and light have to be converted into the same unit?"Change the stimulus strength and see whether the firing rate follows
Rules vs. learning"When the environment changes, who adapts first?"Click "Change environment" and compare the two flies' success rates
② Perceptron"Can a single straight line separate a band shape?"Run training on the band problem and see where the accuracy stalls
③ Hidden layer"Is adding more hidden neurons always better?"With little data + 40 hidden neurons, look at the gap between training and validation scores
④ Many layers"Why doesn't the fly jump at objects passing by?"Click approaching, passing and receding in turn
Hands-on: Trainer example"Why were both models confused by the same drawings?"Click the test drawing buttons in turn and compare with the confusion matrix

Top 5 common misconceptions

MisconceptionCorrect explanationScene to show
The fruit fly brain works exactly like deep learningOnly the layered structure and learning of connection strengths are similar; backpropagation and timeless computation differ from the brainThe "Backpropagation" row in Analogies D
More hidden neurons are always betterWith little data, the model memorizes the training data and the validation score drops (overfitting)The low-data setting in ③
With well-written rules, you don't need learningWhen the environment changes, rules keep getting it wrong. Learning adjusts again"Change environment" in "Rules vs. learning"
High accuracy means a good modelAccuracy measured on the training data is hard to trust. Measure it on validation data set aside separatelyTraining/validation curves in the Trainer example (training 100%, validation 83–89%)
The fly-style model is worse than deep learningWith only a quarter as many trained connections, it reached similar accuracy on the same drawing task (Code 2)Results table of Code 2

Check questions (click to expand the explanations)

Q1. What is the output of a perceptron with two inputs (1, 0), weights (0.8, −0.5) and threshold 0.5?

Sum = 1×0.8 + 0×(−0.5) = 0.8. Since 0.8 ≥ 0.5, the output is 1.

Q2. Why can't a perceptron solve the "band-shaped" problem (food only in the middle)?

A perceptron divides with only a single straight line (plane). A band needs two boundaries, one on each side, so one straight line can't separate it. A hidden layer creates several boundaries and combines them.

Q3. If training accuracy is 96% and validation accuracy is 59%, what happened? Name two remedies.

Overfitting. The model memorized the training data. Remedies: any two of collecting more data, using fewer hidden neurons, and stopping training early.

Q4. In the fly-style model, which connections are learned and which are fixed?

Fixed: projection neurons → Kenyon cells (random sparse connections). Learned: Kenyon cells → output neurons (changed by dopamine).

Q5. In Code 2, the fly-style model (4,004 trained connections) reached accuracy similar to the MLP (16,708 trained connections). What does this tell us?

Even with just a wide, sparse, fixed representation, simple drawing problems can be solved well enough by training the output layer alone. However, since the representation itself can't improve, it has limits on harder problems.

Colab assignments

Basic

In Code 1, change TOP (the fraction switched on) from 0.08 to 0.5, report how the training accuracy and the number of active Kenyon cells change, and explain in two sentences why sparsity is useful.

Challenge

Change the MLP hidden size in Code 2 to 8, 64 and 512 and compare validation accuracy across two seeds. Interpret whether overfitting appears, together with the learning curves (cell 7).

Adjusting difficulty and learning more

BeginnersSection ④ and the GRU/LSTM parts of "Comparing structures" can be skipped without breaking the flow. Make sure "Rules vs. learning" and ②③ are solid
AdvancedHave learners present a comparison of the fly-style model with random features and extreme learning machines (ELM) in machine learning. Check any papers they find against the originals
Learn moreSangsun Ahn, "Data Science for Business" lecture notes (data science overview, in Korean) · STEP [K-Digital] Artificial Intelligence: Natural Language Processing · STEP [K-Digital] Fundamentals of Fintech Data Analysis
Instructor materialsGrading criteria for the check questions and sample answers for the assignments are on the Answer Key for Educators page (Special 1)

Great work!

You've read all of "Special 1: Exploring the Fruit Fly Brain." The lab crew will each sum it up for you.

Professor
ProfessorWe followed the fruit fly from senses to behavior and grew a neural network one rung at a time.
  • Senses → nerves → brain → behavior shares the same skeleton as input → hidden layer → output
  • A hidden layer solves the band problem that a perceptron can't
  • Even the fly-style model, with just 4,004 trained connections, reached a test accuracy of 0.84
Assistant
AssistantThe rule-following fly kept getting it wrong once the environment changed!
Fly Researcher
Fly ResearcherMy brain's only 140,000 neurons. And I do everything with it.