Lesson 05

Machine
Learning.

Machine learning is how we teach computers to learn from examples rather than writing rules by hand. Instead of telling a computer "a 7 has a diagonal stroke" — we show it thousands of 7s and let it figure out the pattern itself.

Training Data

A large set of labelled examples the model learns from. For digit recognition: 60,000 handwritten digits, each tagged with the correct answer.

Neural Network

Layers of interconnected nodes that transform raw input pixels into increasingly abstract features until a final prediction emerges.

🎯
Training

The model makes predictions, measures its errors with a loss function, then nudges its weights — repeated many times until accurate.

The MNIST dataset — 70,000 handwritten digit images (28×28 px, 0–9). It has been the standard benchmark for image classifiers since 1998.

How digit recognition works

Every step below runs inside your browser using TensorFlow.js.

✏️Step 1You Draw
🔲Step 228×28 px
📐Step 3Normalize
Step 4 Neural Net
Step 510 Scores
Step 6Prediction
x₁ x₂ x₃ h₁ h₂ h₃ h₄ y₁ y₂ y₃ Input Hidden Output

Inside a neural network

Each node receives inputs from the layer before it, multiplies each by a learned weight, sums them, adds a bias, then passes through an activation function.

Formula: y = ReLU(Σ wᵢxᵢ + b)

Our model uses two hidden layers (128 and 64 neurons) plus a final softmax layer that outputs 10 probabilities — one per digit.

Activity — Draw a Digit

Draw any digit (0–9) below. The neural network will show its confidence for each possibility.

Digit Recognizer
⏳ Loading neural network…
Draw here
Model sees
28×28 px
? Confidence: