Skip to content
Kudos AI

Neural Network From Scratch

A feed-forward network in NumPy with hand-derived backpropagation, validated against numerical gradients so the calculus is proven rather than trusted.

Python (NumPy)active

A multilayer perceptron written with nothing but NumPy, built to make backpropagation concrete. The forward pass, the loss, and the analytic gradients for every layer are derived by hand and then implemented directly, and the central discipline of the project is gradient checking: each analytic gradient is compared against a finite-difference estimate, and the implementation is only accepted when the relative error falls to the order of 1e-7. That check is what turns backpropagation from a formula the reader has seen into one they have verified. The network is then trained on XOR - chosen because no single linear layer can represent it, which makes the need for a hidden layer a demonstrated fact rather than an assertion. Implementation is in progress and no source repository has been published yet.

Highlights

  • Analytic gradients derived per layer and checked against finite differences to ~1e-7 relative error
  • XOR used as the worked case, with the linear-separability argument shown before the network is built
  • Activation, loss, and initialisation each swappable to expose their effect on convergence
  • No autograd anywhere - the chain rule is written out, not delegated

Related articles

8 min readNeural Networks

What Is a Neural Network?

Layers as parameterised transformations, the forward pass, and why depth and non-linearity are not optional: a proof that no single linear layer can compute XOR, and a two-layer network that does, worked entirely by hand.

Deep LearningMathematics
8 min readNeural Networks

Backpropagation and Gradient Descent

How a neural network learns: the loss as a function of weights, gradient descent, and backpropagation as the chain rule applied backwards, with every partial derivative of a small network computed by hand and checked against autograd.

Deep LearningOptimizationMathematics