Back to Projects
Deep Learning Fundamentals

Neural Network Manual Backpropagation

A single training step of a small neural network written by hand in NumPy, without TensorFlow or PyTorch, to show exactly what a framework automates.

Type
From-Scratch Implementation
Domain
Recommendation scenario (course)
Methods
Manual Forward and Backward Pass
Origin
Cambridge DS Career Accelerator coursework

The Challenge

One complete training step of a 2-2-1 neural network, forward pass, backpropagation and weight update, was written by hand in NumPy.

Before relying on a deep-learning framework, the goal was to compute every step of training explicitly, so that gradients, activations and learning rates are understood rather than taken on trust.

Approach

01
Network definition
A 2-2-1 network with given weights and biases: two inputs (the course's recommendation scenario), a two-neuron ReLU hidden layer and a sigmoid output.
02
Forward pass
Hidden activations via ReLU and the prediction via sigmoid for the input [0.3, 0.4], giving an output of 0.9209 against a target of 1.
03
Backward pass
Loss gradient derived and propagated through both layers by hand.
04
Update
One gradient-descent update of all weights and biases at a learning rate of 0.02.

Try it: one training step, computed live

LIVE COMPUTATIONLIVE COMPUTATION2-2-1 NETWORK2-2-1 NETWORK

Weights, biases, input, target (1) and learning rate (0.02) are the project's own. Every number above is calculated in your browser as you step through. Loss: ½(target − output)².

Results

2-2-1
Network computed entirely by hand
0.9209
Prediction before the update (target 1)
Zero
Deep-learning frameworks used

Working through the maths shows what frameworks automate, which helps when diagnosing problems such as vanishing gradients, poor activation choices or learning-rate sensitivity in larger models.

How it was tested

TEST REPORTTEST REPORTBACKPROPAGATIONBACKPROPAGATION
Checked
  • The forward pass gives 0.9209 for the input [0.3, 0.4], and the live demo above reproduces it from the same weights, biases and learning rate.
  • The demo's updated weights and biases match the values printed in the original notebook.
Limits
  • One training step on one input: it shows the mechanics of training, not model performance.

Technology Stack

Python NumPy Manual Backpropagation Gradient Descent
Interested in this work or something similar?