Build a Tiny Neural Network by Hand: Forward Pass, Loss, and Training
Build a neural network you can actually explain
Lots of people use neural networks without knowing what happens inside them. This tutorial fixes that—not with a giant framework, but with a tiny network you write in plain Python.
What you’ll build
A model that predicts whether a student passes based on study hours (and later, sleep hours too). Four rows of data. One neuron. Real training loop. No magic.
| Study Hours | Passed |
|---|---|
| 1 | 0 |
| 2 | 0 |
| 3 | 1 |
| 4 | 1 |
This is not production ML. It is a learning example so you can see every step.
What you’ll learn
- What a neuron does (input, weight, bias, output)
- How sigmoid turns a raw number into a probability
- What loss means and why training tries to shrink it
- How a simple loop updates weights—an honest preview of backpropagation
- How adding a second input changes the same math
Tutorial structure (7 pages, ~45 minutes)
- The problem & the idea — dataset, what a neural network is
- One neuron — forward pass by hand, first exercise
- Sigmoid & decisions — probabilities, threshold, honesty about “thinking”
- Loss & training — squared error, training loop, live code
- Check your model — predictions, tuning exercises, short quiz
- Two inputs — study + sleep, tabs for pure Python vs NumPy peek
- Backprop, limits & final quiz — what we skipped, recap, knowledge check
Interactive pieces along the way
- Animated flows and diagrams for forward pass and training
- Drag-and-drop: order the training steps
- Live Python runners you can edit and run
- Quizzes on pages 5 and 7
Prerequisites
- Basic Python
- Simple math (multiply, subtract, square)
- No TensorFlow, PyTorch, or deep learning background required
Code repository
Runnable samples live in githubRepo/2026/05/20/tiny-neural-network-by-hand/. Same code as the tutorial—copy, run, break things on purpose.
Quick preview
A neural network here is just small math units chained together. Each unit does:
output = input × weight + bias
Training means: predict → measure error → nudge weights → repeat. That pattern scales all the way up to huge models. You’re learning the core loop first.
Ready? Hit Start Tutorial above.
Discussion
Loading comments...