By AI Fundamentals Team

Build a Tiny Neural Network by Hand: Forward Pass, Loss, and Training

Intermediate 45 min
AINeural NetworksMachine LearningPythonFundamentals

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 HoursPassed
10
20
31
41

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)

  1. The problem & the idea — dataset, what a neural network is
  2. One neuron — forward pass by hand, first exercise
  3. Sigmoid & decisions — probabilities, threshold, honesty about “thinking”
  4. Loss & training — squared error, training loop, live code
  5. Check your model — predictions, tuning exercises, short quiz
  6. Two inputs — study + sleep, tabs for pure Python vs NumPy peek
  7. 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

Join the conversation and share your thoughts

Discussion

0 / 5000