Back to all work
Machine Learning· 2024· Project lead, team of 4Shipped

CNN for Image Classification

Custom CNN vs four canonical architectures on MNIST - how much does architecture actually matter?

CNN for Image Classification

The question behind this Pattern Recognition project: how much does architecture actually matter? Rather than take the textbook answer on faith, we tested it - a custom-built CNN against four canonical pretrained architectures, all on MNIST digit classification, all evaluated the same way. Each team member owned one pretrained architecture (DenseNet, ResNet, GoogLeNet, VGG) so the comparison covered the field.

My Contribution

As project lead, I handled model design and training, hyperparameter optimization, and performance evaluation for both the custom Convolutional Neural Network and the DenseNet architecture, achieving significant improvements in accuracy and model convergence.

Part 1: Custom CNN for Image Classification

The baseline had to be honest, so the custom CNN got the same discipline as the pretrained models: proper train/validation/test splits, exploratory analysis of the dataset, and evaluation beyond a single accuracy number.

Repository: Custom CNN Implementation

Class Distribution of the Dataset
Class Distribution of the Dataset.
PCA on MNIST Dataset
PCA on MNIST Dataset.
  • Custom CNN architecture built using PyTorch.
  • Dataset split into training, validation, and testing sets.
  • Comprehensive evaluation using metrics like accuracy, confusion matrix, precision, and recall.

Training and Validation loss curves:

Training and Validation Loss Curves

Part 2: State-of-the-Art CNN Implementations

Each team member implemented and fine-tuned a pre-trained CNN architecture against the same task:

DenseNet: Fine-tuned for accuracy improvements and faster convergence.

DenseNet Architecture
DenseNet Architecture
DenseNet Training Curve
Training Curve.

ResNet: Utilized residual connections for handling deeper layers.

ResNet Architecture
ResNet Architecture.
ResNet Training Curve
Training Curve.

GoogLeNet: Fine-tuned for complex image classification tasks.

GoogLeNet Architecture
GoogLeNet Architecture
GoogLeNet Training Curve
Training Curve.

VGG: Optimized for feature extraction.

Results

Custom CNN 99.14%
DenseNet 99.28%
ResNet 99.56%
GoogLeNet 99.04%
VGG 99.15%

The spread is the finding. Every model lands between 99.04% and 99.56%, and the hand-built CNN (99.14%) sits within half a percentage point of fine-tuned ResNet (99.56%) - it even edges out GoogLeNet. On a dataset as saturated as MNIST, disciplined training - clean splits, tuned hyperparameters, honest evaluation - buys more than architectural sophistication. That, rather than any single accuracy number, was the real lesson of running the comparison ourselves.

Contributors

For more details and to explore the implementation, visit the GitHub Organization.