This book is licensed for the personal use of the buyer. Please do not share or resell the file. Short quotations with attribution are welcome.
The information in this book is provided for education. It is not legal, financial or other professional advice. Product and company names are used only to describe them and belong to their owners.
This is a free sample: the introduction and first chapter.
IntroductionIntroduction
Deep-learning libraries let you train a neural network in a dozen lines without understanding a single step. That convenience has a cost: when training fails, as it often does, you have no idea why. Loss curves that explode, accuracy stuck at chance, models that memorise instead of learning: each has causes you can diagnose only if you know what happens inside.
This book takes the opposite route. You will build a neural network from first principles, piece by piece: a single neuron, then layers, activation functions, loss functions, backpropagation and gradient descent. You will then improve training with initialisation, better optimisers, normalisation and regularisation, and finally connect your from-scratch network to the convolutional and transformer architectures used today.
Each step comes with small calculations you can check by hand and short Python examples that use only basic arrays (NumPy). By the end, nothing in a neural network should feel mysterious.
How the book is organised
Chapters 1 to 8: neurons, activations, layers, forward passes and loss functions.
Chapters 9 to 15: gradients, backpropagation, gradient descent and a complete network trained from scratch.
Chapters 16 to 24: making training work: initialisation, learning rates, momentum and Adam, normalisation, regularisation, dropout, early stopping and debugging.
Chapters 25 to 29: debugging, then from your network to modern architectures: convolutions, sequences, attention and transformers.
Chapters 30 to 35: going deeper: a two-layer backward pass by hand, a multi-class training loop, evaluation, text classification, hyperparameter search and what networks learn.
Chapters 36 to 39: regression networks, autoencoders, transfer learning, and saving and deploying models.
Chapters 40 to 42: frameworks, a practical recipe and next steps.
Exercises and a glossary close the book.
Chapter 1What a Neural Network Is
A neural network is a function that turns inputs into outputs through layers of simple computations, with many adjustable numbers called weights. Training finds weights that make the outputs match examples.
The recipe
Forward pass: compute outputs from inputs.
Loss: measure how wrong the outputs are.
Backward pass: compute how each weight affects the loss.
Update: adjust each weight slightly to reduce the loss.
Repeat over many examples.
Why "neural"?
The name comes from a loose analogy with brain cells that receive signals and fire. Modern networks owe little to biology; they are better understood as flexible mathematical functions.
You have reached the end of the free sample. The full book continues with 41 more chapters, plus the appendices.