Make Your Own Neural Network: Book Summary + MNIST Digit Recognizer in NumPy

make your own neural network book summary with MNIST handwritten digit recognizer built in pure NumPy

Updated October 2026 | 15 min read

Make Your Own Neural Network by Tariq Rashid is the book most people recommend when someone asks “how do I actually understand neural networks, not just use them?” Published in 2016, it has become the gentlest serious introduction in print — it assumes nothing beyond school maths, builds every idea with pictures before code, and ends with you training a network that reads handwritten digits.

Two things up front. First, this page is not a copy of the book and the book is not free — it’s a paid book that deserves to be paid for, and the links below take you to buy it and to the author’s own free code. Second, what is free here: a summary of what the book teaches and who it’s for, five key ideas in my own words, and a complete MNIST digit recognizer in pure NumPy — my own implementation of the same kind of network the book builds — with tested code, real output, the mistakes you’ll hit, and PDF notes of this page. If you’ve done our neural network from scratch notes (XOR, 4 neurons), this is the same idea scaled up to 784 inputs and real data.

About the Book

Tariq Rashid wrote the book after being frustrated that every neural-network explanation either hid behind libraries or drowned in notation. His answer was a short book in three parts. Part 1 — Ideas builds the concept from scratch: what a neuron does, why we need many of them, how a network learns by adjusting weights, and how matrices make this tidy — with hand-drawn diagrams and no code. Part 2 — DIY with Python turns those ideas into a working network in a few dozen lines of Python and NumPy, then trains it on the MNIST handwritten digits. Part 3 — Even More Fun plays with the result: rotating training images, running the network backwards to see what it “imagines” a digit looks like, and running it on a Raspberry Pi.

The book is for you if… Probably not for you if…
You want to understand what’s inside a neural network You just want to use Keras/PyTorch and ship something
Your maths stopped at school level and you’d like it to stay that way You’re comfortable with calculus and want the full derivation
You learn best from pictures and slow build-up You want a dense reference you can flip through
You’re a student, self-learner, or teacher preparing to explain this You need modern architectures — CNNs, Transformers (see page 3)

It’s deliberately narrow: one network type (feedforward, sigmoid, one hidden layer), one dataset (MNIST), fully understood. That narrowness is the point.

5 Key Lessons From the Book (In My Own Words)

1. A neuron is just a small function

Strip away the biology and a neuron does one thing: take some numbers in, add them up with weights, squash the total through a function, pass the result on. That’s it. The “intelligence” isn’t in any single neuron — it’s in thousands of these simple functions wired together, each one slightly adjusting what it passes forward. Once this clicks, the whole subject stops being mysterious.

2. Matrices aren’t scary — they’re a filing system

A layer of 100 neurons each connected to 784 inputs means 78,400 weights. Writing 78,400 multiplications by hand is absurd; writing one matrix multiplication is one line. The book’s insight is that matrix maths isn’t an extra topic you need to learn — it’s just the natural way to write “do the same thing to every connection at once.” In NumPy that’s the @ operator, and it’s why the whole network fits in a screenful of code.

3. Why the activation function has to bend

If every neuron only added and multiplied, the whole network — no matter how many layers — would collapse into one straight-line function and couldn’t learn anything curved. The sigmoid’s S-shape is what lets the network bend. Rashid also explains the practical consequence most tutorials skip: since sigmoid can never actually output 0 or 1, you shouldn’t ask it to — use 0.01 and 0.99 as targets instead. (That’s Common Mistake 2 below.)

4. Backpropagation is blame-sharing

When the output is wrong, who’s at fault? The book’s answer is intuitive: share the blame backwards in proportion to the weights. A connection with a big weight contributed more to the error, so it gets more of the blame and a bigger correction. Do this layer by layer from the output back to the input and you’ve got backpropagation — the same thing page 1 does with d_hidden = d_output.dot(w2.T), now explained as a story instead of a formula.

5. The learning rate is a step size, and smaller isn’t always better

Each correction is scaled by a learning rate. Too large and the network overshoots and oscillates; too small and it crawls — or gets stuck. The book shows this with actual experiments on MNIST, and the result surprises people: 0.1 isn’t automatically safer than 0.3. You have to try values and look at the accuracy. We do exactly that in the table below.

Hands-On: MNIST Digit Recognizer in Pure NumPy

The book’s core project is a 784 → 100 → 10 network: 784 input pixels (a 28×28 image flattened), 100 hidden neurons, 10 outputs (one per digit). Here’s my own implementation, written to be read top to bottom. It’s the same algorithm as page 1’s XOR network, just bigger and trained on 60,000 real images.

make your own neural network – 784-100-10 network diagram for MNIST digit recognition

Step 1 — Load MNIST

MNIST is 70,000 images of handwritten digits. The easiest way to get it as NumPy arrays is through Keras (it downloads ~11 MB once, then caches). We only use Keras to download MNIST — the network itself is pure NumPy. If you don’t have TensorFlow installed and don’t want it just for this, the alternative is sklearn.datasets.fetch_openml("mnist_784") — same data, one extra line to split it.

🐍 Python
import numpy as np
from tensorflow import keras

np.random.seed(42)

(X_train, y_train), (X_test, y_test) = keras.datasets.mnist.load_data()

# flatten 28×28 → 784, then scale pixels to 0.01–0.99 (never exactly 0)
X_train = X_train.reshape(-1, 784) / 255.0 * 0.99 + 0.01
X_test  = X_test.reshape(-1, 784)  / 255.0 * 0.99 + 0.01

print(X_train.shape, X_test.shape)
(60000, 784) (10000, 784)

That scaling line matters: pixel values of exactly 0 would zero out their weights’ updates forever (because the update multiplies by the input). Shifting everything to 0.01–0.99 keeps every connection alive. The book makes a point of this and it’s the first mistake people make when they skip it.

Step 2 — The network

🐍 Python
def sigmoid(x):
    return 1 / (1 + np.exp(-x))

class DigitNet:
    def __init__(self, n_in=784, n_hidden=100, n_out=10, lr=0.1):
        self.lr = lr
        # weights scaled by 1/sqrt(incoming connections) — keeps early signals sane
        self.w1 = np.random.normal(0, n_in ** -0.5,     (n_hidden, n_in))
        self.w2 = np.random.normal(0, n_hidden ** -0.5, (n_out, n_hidden))

    def forward(self, x):
        x = x.reshape(-1, 1)                 # column vector (784, 1)
        h = sigmoid(self.w1 @ x)             # (100, 1)
        o = sigmoid(self.w2 @ h)             # (10, 1)
        return x, h, o

    def train(self, x, target):
        x, h, o = self.forward(x)
        t = target.reshape(-1, 1)
        err_o = t - o                        # output error
        err_h = self.w2.T @ err_o            # share blame back to hidden layer
        self.w2 += self.lr * (err_o * o * (1 - o)) @ h.T
        self.w1 += self.lr * (err_h * h * (1 - h)) @ x.T

    def predict(self, x):
        return np.argmax(self.forward(x)[2])

Two things to notice. First, there’s no bias term — the book leaves it out, and MNIST has enough signal in 784 inputs that it works anyway. On page 1, XOR with 2 inputs couldn’t learn without bias; this is why. Second, train() is page 1’s loop body: forward, error, blame-share backwards, update. Compare err_h = self.w2.T @ err_o here to d_hidden = d_output.dot(w2.T) there — same idea, different shape convention.

Step 3 — Train one epoch and test

The book trains one example at a time, which is slow in Python — about 1–2 minutes per epoch on a laptop — but makes every step visible. We’ll do the same.

🐍 Python
net = DigitNet(lr=0.1)

# targets: 0.01 everywhere, 0.99 at the correct digit (sigmoid can't hit 0 or 1)
def make_target(label):
    t = np.full(10, 0.01)
    t[label] = 0.99
    return t

# one pass over all 60,000 training images
for x, label in zip(X_train, y_train):
    net.train(x, make_target(label))

# accuracy on the 10,000 test images it has never seen
correct = sum(net.predict(x) == label for x, label in zip(X_test, y_test))
print(f"Test accuracy after 1 epoch: {correct / len(X_test):.4f}")
Test accuracy after 1 epoch: 0.9493 ← ≈ 94–95%; exact value varies slightly by NumPy version

About 95% of handwritten digits read correctly, after one pass, from a network you can read in full in under 30 lines. That’s the book’s whole argument made real: you don’t need a framework to understand this, and understanding it is within reach.

Step 4 — Test it on your own handwriting

Draw a digit in any paint program — black pen on white, roughly square — save it as my_digit.png, and run:

🐍 Python
from PIL import Image   # pip install pillow

img = Image.open("my_digit.png").convert("L").resize((28, 28))
pixels = 255 - np.array(img).reshape(784)   # invert: MNIST is white-on-black
x = pixels / 255.0 * 0.99 + 0.01

print("The network thinks this is a:", net.predict(x))

The inversion line is the one people forget: MNIST digits are white strokes on a black background, so a normal drawing (black on white) has to be flipped first. If your 7s keep coming back as 1s, draw them bigger and more centred — MNIST digits fill most of the 28×28 box.

Real Results: Epochs, Learning Rate, Hidden Neurons

The book’s best section is where it stops explaining and starts experimenting. Here’s the same spirit — change one knob, retrain, measure. Each row is a full run from scratch with np.random.seed(42).

Epochs Learning rate Hidden neurons Test accuracy Note
1 0.1 100 ≈ 94.9% The baseline above
3 0.1 100 ≈ 96.5% More passes help — up to a point
1 0.3 100 ≈ 94.5% Faster early, slightly noisier
1 0.1 200 ≈ 95.5% More capacity, ~2× slower

These are typical values; your exact numbers will differ by a few tenths of a percent depending on NumPy version. The pattern is what matters: epochs help most, more hidden neurons help a little, and a bigger learning rate isn’t automatically better.

Run the epochs loop below and you’ll see the curve flatten: roughly 94.9% → 96.2% → 96.5% → 96.7% → 96.6% across epochs 1–5. Notice accuracy flattens after epoch 3–4, and even dips slightly at 5 — more epochs aren’t free improvement. Past that point the network starts memorising the training set rather than learning digits, and you’d need the techniques from the book’s Part 3 (like rotated training images) to go further.

To draw the accuracy-vs-epochs curve yourself, wrap the training loop and record accuracy after each pass:

🐍 Python
import matplotlib.pyplot as plt

np.random.seed(42)
net = DigitNet(lr=0.1)
history = []

for epoch in range(1, 6):
    for x, label in zip(X_train, y_train):
        net.train(x, make_target(label))
    acc = np.mean([net.predict(x) == l for x, l in zip(X_test, y_test)])
    history.append(acc)
    print(f"Epoch {epoch}: {acc:.4f}")

plt.plot(range(1, 6), history, marker="o")
plt.title("MNIST accuracy vs epochs (784-100-10, lr=0.1)")
plt.xlabel("Epoch"); plt.ylabel("Test accuracy")
plt.savefig("accuracy_vs_epochs.png", dpi=150, bbox_inches="tight")
plt.show()

make your own neural network – MNIST test accuracy vs epochs chart for 784-100-10 NumPy network

Common Mistakes (and What You’ll See)

Mistake 1: Inputs not scaled to 0.01–0.99

What you see: Accuracy stuck around 10–30% no matter how long you train, or RuntimeWarning: overflow encountered in exp.
Cause: Feeding raw pixels (0–255). Large inputs push sigmoid into its flat regions where the gradient is almost zero, so weights barely move. And exact zeros kill their weights’ updates entirely.
Fix: pixels / 255.0 * 0.99 + 0.01 — every input between 0.01 and 0.99, none exactly zero.

Mistake 2: Targets of 0 and 1 instead of 0.01 and 0.99

What you see: Accuracy plateaus a couple of points lower than it should, and weights slowly grow very large.
Cause: Sigmoid can approach 0 and 1 but never reach them. Asking for exactly 1 means the error never fully closes, so the network keeps pushing weights toward infinity trying to get there.
Fix: That’s what make_target does — 0.01 everywhere, 0.99 at the label. Small change, measurable gain.

Mistake 3: Shape errors in the weight update

⬛ Error
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0,
with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 100 is different from 1)

Cause: A missing .T or a missing reshape(-1, 1). The update w2 += lr * (err_o * o * (1-o)) @ h.T needs h.T to be (1, 100) so the result is (10, 100) — the same shape as w2. Forget the transpose and NumPy tries to multiply (10,1) by (100,1).
Fix: Keep every vector as an explicit column — (n, 1), never (n,) — and transpose the one on the right of @ in each update. If in doubt, print(h.shape, err_o.shape) before the line that fails.

The Book vs This Tutorial vs Keras

  The book This page Keras (page 3)
Goal Understand, slowly, with pictures Summarise + build it in modern NumPy Build fast, scale up
Lines of network code ~40 ~30 (same algorithm, @ operator) ~10
Bias term No No (explained why) Yes, automatic
Speed 1–2 min/epoch 1–2 min/epoch ~10 s/epoch
MNIST accuracy ~95–97% ~95–97% ~98–99% (CNN)
Best for First understanding Quick refresher + project Real work

The honest path is all three in order: the book (or page 1 + this page) to understand it, then types of neural networks + Keras to use it. Skip the first step and Keras stays a black box.

Where to Buy the Book (and the Author’s Free Code)

Please don’t search for a pirated PDF. The book is cheap, the author’s code is already free and official, and the summary on this page tells you whether it’s worth your money before you spend it.

Exercises (Straight From the Spirit of Part 3)

  • Rotate for augmentation. Use scipy.ndimage.rotate(img.reshape(28,28), 10, reshape=False) to create ±10° copies of each training image and train on the enlarged set. The book shows this nudges accuracy up — does it for you? By how much?
  • Add a second hidden layer. Make it 784 → 100 → 50 → 10. You’ll need a w3, one more forward step, and one more blame-sharing step in train. Does it beat 100 neurons in one layer, for the same training time?
  • Run it backwards. Feed a target like [0.01, …, 0.99, …, 0.01] (a “perfect 3”) into the output and push it backwards through the transposed weights to the input — then reshape to 28×28 and imshow it. You’ll see what the network “thinks” a 3 looks like. This is the book’s most memorable trick.

📥 Download: Notes PDF + mnist_numpy.py

Free from TechProFree: with mnist_numpy.py (everything on this page in one runnable file, with the epochs loop) plus a PDF of these notes — the summary, the five lessons, the code, the results table and the mistakes. No signup required. The book is not included — see the buy links above.

Final Thoughts

Make Your Own Neural Network earns its reputation by doing one thing properly: it makes you build the thing, slowly, until you can’t un-understand it. The network on this page is that same network in modern NumPy — if you can read train() and explain each line, you’ve got what the book is for.

Run it, draw your own digit, try the exercises. Then go to page 3 and watch Keras do in ten lines what you just did in thirty — and notice that this time, you know exactly what it’s doing.

Did your handwritten digit get recognised? What accuracy did you reach? Drop a comment — I read and reply to every one.

Frequently Asked Questions (FAQ)

Is Make Your Own Neural Network free?

No — it’s a paid book, available in paperback and Kindle. What is free is the author’s own code on GitHub, which he released officially, and the notes and NumPy project on this page. This page is a summary and companion project, not a copy of the book.

Is Make Your Own Neural Network good for beginners?

It’s one of the best starting points there is. It assumes only school maths, builds every idea with diagrams before any code, and ends with a working digit recognizer. If you’ve never understood what happens inside a neural network, this is the book that fixes that.

How much maths do I need for this book?

Basic algebra and the idea of a gradient (which the book explains from scratch with pictures). Matrix multiplication is introduced gently as “do the same thing to every connection at once.” You don’t need calculus — the book deliberately shows the one derivative it uses and then moves on.

Is the book better than an online course?

Different job. Online courses are usually about using a framework; this book is about understanding the mechanism. Most people benefit from the book (or a from-scratch tutorial like this) first, then a course on Keras or PyTorch. Doing it the other way round leaves the framework feeling like magic.

Can I download these notes as a PDF?

Yes — the free PDF notes and the mnist_numpy.py file are linked above. They cover the summary, the five lessons, the full code with output, the results table and the common mistakes. The book itself is sold separately; buy links are above.