Deep Learning
Three studies that climb the deep-learning ladder. The first implements a feedforward network and its backpropagation from scratch in pure NumPy. The second moves to convolutional networks across three image datasets, ending in transfer learning that jumps from ~68% to ~95% accuracy. The third trains a Double DQN agent to clean a grid world, scaling from a 5×5 board up to 15×15.
Understand the internals, then stand on the frameworks
The three studies are deliberately ordered. First, build a network with no framework at all — every weight update written by hand — so the mechanics are not a black box. Then switch to TensorFlow/Keras to do the things that are impractical from scratch: convolutions, augmentation, pretrained backbones. Finally, push the same tools into decision-making with reinforcement learning.
Each study ends on an honest finding rather than just a number — where ReLU dies, where extra layers hurt, where a larger grid stops learning — because the failures were where most of the understanding came from.
Three studies, three model structures
A feedforward network and backprop in pure NumPy
The first study implements a small feedforward network — two inputs, two 16-unit hidden layers, one output — entirely in NumPy, with He initialisation, ReLU and Sigmoid activations and their derivatives, and full backpropagation updating every weight and bias by hand. The task is to learn the product function f(x, y) = x · y from 100,000 synthetic samples.
ReLU reached an RMSE of about 0.049 against a 0.25 baseline and converged faster than Sigmoid, which was both slower (43 vs 26 minutes over 20k epochs) and less accurate. Pushing ReLU onto the output layer reproduced the classic "dying ReLU" — loss flatlining around 0.334 — a textbook failure made concrete by having built every step.
Three datasets, from scratch to pretrained
CIFAR-10 — custom CNN
A from-scratch convolutional stack (32 → 64 → 128 feature maps with max-pooling, then dense layers) trained with Adam reached about 71.5% validation accuracy on the ten-class set — well above chance, honestly assessed as "not high".
CIFAR-100 — deeper & regularised
A deeper network with data augmentation, BatchNormalization and a cosine-decay SGD schedule with Nesterov momentum reached ~66.5% across one hundred fine-grained classes, meeting the target despite the harder split.
Animal-10 — transfer learning
Swapping in a pretrained ResNet50V2 backbone took accuracy from ~68% (trained from scratch) to ~95.5% on a 26k-image, ten-animal dataset — the headline lesson in standing on pretrained features.
Head-design ablation
Comparing four classifier heads on the ResNet backbone showed the simplest one wins: a global-average-pool plus a small dense head beat heavier variants, where extra layers and a sigmoid stage only added overfitting or interference.
A Double DQN agent that cleans a grid
A custom gymnasium-style environment places p dirty tiles on an m×n grid; the agent sees a multi-channel image state (its own position and the dirt map) and moves in four directions, rewarded for cleaning and completion and penalised per step and for hitting walls. A Double DQN — separate online and target convolutional networks — learns the policy with a 500k-capacity replay buffer, ε-greedy exploration decaying from 1.0 to 0.01, soft target updates at τ = 0.005, Huber loss and gradient clipping.
It scales from a 5×5 board up to 15×15, where success on fixed dirt positions climbed to roughly 95% — while randomising the dirt each episode destabilised learning, a clear lesson in how much the problem setup decides whether an agent learns at all.
What it's built on
- From scratch
- NumPyManual backpropHe initReLU / Sigmoid
- Frameworks
- TensorFlowKerasResNet50V2Data augmentation
- Reinforcement learning
- Double DQNReplay bufferε-greedyHuber loss
- Tooling
- Pygamegymnasium-style envPython
Three solo studies up the deep-learning ladder — a network and backprop built by hand in NumPy, CNNs and transfer learning to ~95% accuracy, and a Double DQN agent cleaning a grid — each ending on what actually broke and why.
