A neural network is a combination of a few building blocks: neurons that weigh their inputs, activation functions that bend the signal, hidden layers that stack up, loss functions that measure how wrong the output is, and backpropagation, which hands out blame backward to fix the weights. You will move each block yourself, and at the end you will follow the full workflow of building a real model from these blocks, evaluating it, and deploying it.
y = step(w₁x₁ + w₂x₂ + b)Rosenblatt, 1958
When a fruit smell and a vinegar smell arrive together, a neuron receives the two signals at different strengths and adds them up. If the sum crosses the firing threshold, it sends an "approach" signal. Synaptic strength is the weight, and the firing threshold is the bias.
Multiply each input by its weight, add them up, and add the bias to get z. If z is 0 or more, output 1; otherwise output 0. Seen on a plane, a single straight line w₁x₁ + w₂x₂ + b = 0 separates "food" from "not food." Each time it meets a misclassified point, the perceptron moves the line a little toward that point. That is the perceptron's learning rule.
The perceptron's learning rule is one line. Pick one misclassified point and apply w ← w + η·(target − prediction)·x. If the target was 1 but it said 0, pull the line toward that point; in the opposite case, push it away. For a linearly separable problem, this rule alone will eventually get every point right.
A problem like XOR, "food only when exactly one of the two is present," cannot be split by any straight line. After Minsky and Papert proved this limitation mathematically in 1969, neural network research stalled for a while. The solution is to add one more layer: the hidden layer. But first, let's look at functions that bend smoothly instead of stepping.
An activation function takes the weighted sum z and decides the neuron's output a. It needs a bend for stacking layers to mean anything, and the shape of its gradient (derivative) governs how fast learning goes.
Backpropagation multiplies by the activation function's gradient each time it goes back through a layer. The sigmoid's gradient is at most 0.25. Going back through 10 layers shrinks the signal to at most 0.25¹⁰ ≈ 0.00000095 times its size. Almost no "fix this" signal reaches the early layers. This is the vanishing gradient problem.
ReLU's gradient is exactly 1 in the positive range, so the signal does not shrink no matter how many layers it goes back through, and the computation is just "compare with 0," so it is fast. On the other hand, its gradient is 0 in the negative range, so a neuron that has switched off may never come back. Variants such as Leaky ReLU, ELU, and Swish try to fill this gap. No function is always the best; you choose according to the problem and the model.
Dots (pixels) → directions → junctions → shapes. Each layer uses the previous layer's features as material to build features one step larger.
Weigh the 4 features from the previous layer (0.8, 0.1, 0.4, 0.0) with the weights (0.5, 0.3, 0.2, 0.1) and add a bias of 0.1.
The direction and junction detectors in the figure above are rules a person set in advance for the sake of explanation. Older machine learning really did have people design features this way. Deep learning learns the weights of these detectors from the data by itself. That is why it also finds features people did not think of.
What features actually form at each layer for images is covered in 3-3 (Images and CNNs).
Learning means reducing the loss. What you choose as the loss changes what the model "fears."
(target − prediction)². The default for regression problems, where you predict a number. Used to predict continuous values such as house prices, household spending, or temperature. The backpropagation dashboard below uses this loss.
−log(probability given to the correct answer). The default for classification problems. Being confidently wrong makes the penalty grow without limit. It pairs with a sigmoid or softmax at the output.
With a sigmoid at the output, the MSE gradient becomes 2(p − t)·p(1 − p). If the target is 1 and the model is confidently wrong with p = 0.01, p(1 − p) is close to 0, so the gradient is almost 0 too. It is badly wrong, yet the "fix this" signal is weak. With cross-entropy, the sigmoid's derivative cancels out neatly and the gradient is simply p − t, that is, −0.99. The more wrong it is, the harder it corrects.
Input 2 → hidden 3 → output 1Target 1.00 · loss = (target − output)² · learning rate 0.1
The input is computed along the connections all the way to the output. The first output is 0.41.
(1.00 − 0.41)² ≈ 0.35. This is the MSE from section 5 above.
Going backward from the output, compute each weight's share of the blame (its gradient).
New weight = old weight − learning rate × gradient. This is gradient descent.
Click a weight cell to highlight that connection in the figure, and "Follow the numbers" below shows that weight's calculation.
The error amount at the output, −2 × (target − output), is determined first. The blame for a hidden→output weight is this multiplied by the signal that came in through that weight (the hidden value). An input→hidden weight goes back one more step: multiply by the output weight v to send the blame to the hidden neuron, multiply by h(1 − h) for how sensitive the hidden neuron was, and multiply by the incoming input x. This "multiply and send backward" is the chain rule. The vanishing gradients from section 2 also arise from exactly this multiplication.
Clicking "Output side only (fruit fly style)" freezes the input→hidden weights, and a teaching signal coming down from above (likened to dopamine in the fruit fly) fixes only the output-side connections. This is a heavily simplified analogy of the learning structure in the fruit fly's mushroom body, and whether the dopamine signal is computed like a gradient is still under research.
If you draw the loss as terrain, learning means walking down to find the lowest point. Even looking at the same gradient, each optimizer moves its steps differently.
This valley is long horizontally and steep vertically. SGD moves only as much as the gradient, so in the steep vertical direction it bounces up and down with big steps (zigzag), and with a small learning rate it crawls along the gentle horizontal direction (check this with "0.1 Small"). Momentum remembers the speed it has built up, so it accelerates in the consistent direction (horizontal) while the zigzags cancel each other out. Adam measures the gradient size separately for each direction and adjusts the step size, so it descends horizontally and vertically at a similar pace.
"Mini-batch noise" is the jitter that comes from computing the gradient on only part of the data, as in real training. Set the learning rate to "Large" and SGD bounces over the valley walls. No optimizer always wins. Adam is widely used because it is a safe default for most problems, but there is also research showing that well-tuned SGD generalized better to unseen data on several deep learning tasks [R12].
14 training points · 80 validation pointsInput 1 → hidden 48 (tanh) → output 1, Adam
The surest remedy is to collect more data. With little data and a big model, memorizing is easy. The numbers in this figure come from an illustrative experiment computed directly on this page, and the random seed is fixed so that it gives the same result every time it runs.
All the blocks we have seen so far fit into a single step: training. In real work, what comes before and after is longer. The example is a "find the defects" model for a factory inspection station.
Of 200 inspected products, 20 are actually defective. The model outputs a "probability of being defective" for each product. Try changing the cutoff above which a product is judged defective (the threshold).
Both code examples use only libraries preinstalled in Colab. After "Download notebook (.ipynb)", open it in Colab with File → Upload notebook, or copy the code and paste it into a new notebook cell.
The four steps forward pass → loss → backpropagation → update, written out as-is without libraries. It trains the same spiral data with "no activation function" and with "tanh hidden layers" and compares them. To use your own data, change only X and y in the part of the code marked [To use your own data].
This is how it is done in practice. It compares three models: no activation function / ReLU / ReLU + dropout + early stopping, and saves the last model to a file (step ⑥ Save in section 9).
These are prompts to paste into AI assistants such as ChatGPT, Qwen, or Claude. Pressing "Copy" attaches the chosen code after the prompt. Replace the parts in 〔 〕 with your own situation.
An AI's answer is only a starting point. Always check any papers, figures, or library functions it suggests against the original sources and official documentation. If you used AI help for a competition entry or paper, disclose the fact and extent of its use according to the rules of the organizers and the journal.
This is the same dictionary as the yellow dotted underlines in the text. The same terms are used throughout the series. Click a section name to jump to where the term first appears.
Analogies are a first step to understanding, but they can also seed misunderstanding. Fruit fly and brain analogies are marked by strength. Direct evidence that they actually do the same thing · Partial only some properties are similar · None no known counterpart
| Concept | Everyday analogy | Fruit fly / brain analogy | Where the analogy breaks down |
|---|---|---|---|
| Weight | The different trust you give each opinion | Partial Synaptic strength | Real synapses change strength with time and body state, and their signals are not continuous numbers but electrical pulses (spikes) |
| Bias / threshold | The baseline for making a decision | Partial A neuron's firing threshold | A neuron's threshold is not fixed; it keeps changing with fatigue and adaptation |
| Activation function | A volume knob that has a limit no matter how far you turn it | Partial Firing-rate curve as a function of stimulus strength | A neural network outputs a single number, but a neuron emits pulses over time |
| Hidden layer | A middle manager who gathers and organizes reports | Partial Kenyon cells of the mushroom body | Most input-side connections in the mushroom body do not change through learning. A hidden layer in deep learning learns all of its connections |
| Loss function | A test scoring sheet | Partial Outcomes such as sugar (reward) and electric shock (punishment) | The fruit fly does not compute "how wrong it was" as a single number |
| Backpropagation | Tracing responsibility backward after an accident | None Dopamine signals are not computed backward through layers | Whether the brain does something similar to backpropagation by other means is still under research |
| Learning rate | How much you correct after one piece of feedback | Partial The amount a synapse changes from one experience | How much the brain changes depends on the situation, attention, and repetition |
| Optimizer | How a hiker walks down a foggy mountain | None | A real loss landscape has millions of dimensions, so you cannot see it at a glance like in the figure |
| Overfitting | A student who memorized only the answers to past exam questions | None | People memorize too, but the way people generalize differs from neural networks |
| Dropout | A team that keeps working even when a few members are absent | None Some interpret it as resembling occasional failures of synaptic transmission, but the evidence is weak | At test time all neurons are switched on. Team members are not always absent |
E-1 About the author · E-2 Academic references · E-3 Figure sources
The following materials served as references for structure and content.
A guide for instructors, on-the-job (OJT) trainers, and tutors. Times are estimates; adjust them to your actual class.
| Audience | University students and working professionals learning neural networks for the first time. With basic Python, go as far as the Colab practice; without it, as far as the animations in the main text |
|---|---|
| Prerequisites | Multiplication and addition, and reading function graphs. For derivatives, "gradient = how much it changes when you change it a little" is enough |
| Learning objectives | ① Explain what the perceptron, activation functions, and hidden layers each do ② Follow forward pass → loss → backpropagation → update in numbers ③ Recognize overfitting and respond with validation data, early stopping, and dropout |
| Estimated time | Reading 40–50 min · animation demos 25 min · Colab practice 30 min (Code 1: 10 min, Code 2: 20 min) |
Intro 5 min (demo the XOR failure in section 1) → sections 2·3 demos 15 min → sections 5·6 dashboard 15 min → section 8 overfitting 10 min → check questions 5 min.
Section 6 dashboard 15 min → sections 8·9 25 min (discuss the accuracy trap with work examples) → Code 2 practice 30 min → "apply it to our team's data" with the prompt cards 20 min.
Beginners do only sections 1·2·3·6. Intermediate learners calculate the "Follow the numbers" in section 6 once by hand, then compare it with the backpropagation part of Code 1.
| Section | Questions to pause and ask | Hands-on tips |
|---|---|---|
| 1 Perceptron | "With XOR, why do misclassified points remain no matter how you move the line?" | Train on the easy problem first to show success, then switch to XOR |
| 2 Activation functions | "Where is the sigmoid's gradient at its maximum, and what is that value?" | Stop on the sigmoid, then move the slider to 0 to confirm 0.25 |
| 3 Hidden layers | "We stacked two layers, so why is the left side still a straight line?" | Reduce the number of neurons to 4 to show the right side failing too |
| 4 Representation learning | "Why is □ judged by its 4 corners? What would a person look at?" | Alternate between T and L and point out that only the junction layer changes |
| 5 Loss functions | "When the model is confidently wrong, which loss pushes harder to fix it?" | Set p to 0.01 and compare the two gradient values |
| 6 Backpropagation | "Which has the larger gradient: a weight close to the output or one far from it?" | Run one round slowly with "Next step," then switch between weight cells and read the formulas |
| 7 Optimizers | "Why does SGD zigzag?" | Change the learning rate to "Large" to show SGD bouncing out |
| 8 Overfitting | "If the training loss keeps going down, is it a good model?" | Turn off all regularization and run to the end, then turn each one on in turn and compare |
| 9 Full workflow | "In defect inspection, which costs more: a miss or a false alarm?" | Move the threshold to 0.2 and 0.8 and watch precision and recall move in opposite directions |
| Misconception | Correct explanation | Scene to show |
|---|---|---|
| Stacking more layers always makes it smarter | Without activation functions, any number of layers equals one straight line. Even with them, it overfits when data is scarce | Section 3 left figure, section 8 |
| Neural networks are an exact copy of the brain | They borrowed only the skeleton: layers, connection strengths, and thresholds. Backpropagation has not been confirmed in the brain | The "None" marks in common section D |
| Low training loss means a good model | Performance on unseen data (validation and test) is the standard | Section 8 right graph |
| High accuracy means a good model | On imbalanced data, even "all normal" gets high accuracy. Look at precision and recall together | Section 9, threshold 0.95 |
| Adam is always the best | It is only a safe default. Depending on the problem, SGD + momentum can be better | Section 7, learning rate "Small" |
Only a single straight line (a plane in higher dimensions). Combining linear transformations many times still gives a single linear transformation (W₂W₁x = Wx). The left figure in section 3 is an example.
The sigmoid's gradient is at most 0.25, so it shrinks quickly as it is multiplied at each layer. ReLU's gradient is 1 in the positive range, so it does not shrink going backward. However, it is 0 in the negative range, so dead neurons can appear.
L = (1 − 0.41)² = 0.3481 ≈ 0.35. ∂L/∂y = −2 × (1 − 0.41) = −1.18. These match the first-round values in the section 6 dashboard.
It is overfitting. Use the model from the point where validation loss was lowest (early stopping), turn on dropout or weight decay, or add more data.
Accuracy 90%, recall 0%. It found no defects at all. That is why you must not look at accuracy alone on imbalanced data.
In Code 1, change tanh to ReLU (two lines: the activation function and its derivative). Change the number of hidden neurons to 4, 16, and 64, put the validation accuracy in a table, and write three sentences on the best setting and why.
Replace the data in Code 2 with your own work data (2 or more features, labels 0/1). Split it into training/validation/test at 6:2:2 and report accuracy, precision, and recall on the test data. Judge, with reasons, whether a threshold of 0.5 fits your work.
| Beginners | Sections 4·7 can be skipped without breaking the flow. In section 6, go through just one round together with the "Next step" button |
|---|---|
| Advanced | Have learners calculate the "Follow the numbers" in section 6 by hand, then match it one by one with the d1·d2·d3 lines in Code 1. Discuss what would happen if learning rate decay (a schedule) were added to section 7 |
| Further learning | Sangsun Ahn, “Data Science for Business” lecture notes (data science in general) · STEP [K-Digital] AI Natural Language Processing (linked to 3-5 and 3-8) · STEP [K-Digital] Fundamentals of Fintech Data Analysis (linked to 3-6) |
| Materials for instructors | Grading criteria for the check questions and sample answers for the assignments are on the Answer key for educators page (3-2) |
You've read 「3-2 Building Blocks of Neural Networks」 to the end. Everyone at the lab has a few words to sum it up.