This mini-project is a minimalistic implementation of Convolutional Neural Networks (CNNs) built entirely from scratch using NumPy. I didn’t rely on any deep learning libraries like TensorFlow or PyTorch, the idea was to understand how CNNs works, including both forward and backward passes.
Implemented a zero_pad()
function to pad the input images symmetrically with zeros to preserve spatial dimensions before applying convolution.
conv_single_step()
performs element-wise multiplication of a small filter on a region of the input, this is the core step behind convolution.
conv_forward()
handles a batch of inputs and filters to apply convolution operation over height, width, and channels. It also supports stride and padding hyperparameters.
pool_forward()
supports both max
and average
pooling, reducing dimensionality while preserving features.
conv_backward()
backpropagates through the convolution layer and calculates the gradients w.r.t. input, weights, and biases. Fully vectorized and compatible with batch inputs.
create_mask_from_window()
was used in the pooling backward pass to identify the max element during backpropagation.
distribute_value()
helps in spreading the gradient equally during average pooling backward pass.
pool_backward()
completes the cycle by implementing backward propagation through both max and average pooling layers.
- Python
- NumPy
- No frameworks 😎
This project is great for:
- Learning the internals of CNNs
- Building intuition for backpropagation
- Interview prep
- Academic assignments