How I Reached 91.8% Accuracy on CIFAR-10 – CNN for Image Classification

YESHASHVI RANJAN Avatar

During my internship at Valentius Kryptix, I worked on a task that sits at the heart of modern computer vision: building a Convolutional Neural Network (CNN) that can look at a tiny image and tell what it shows. The goal was ambitious but clear: classify images from the CIFAR-10 dataset and reach at least 85% accuracy on a test set the model had never seen. My final model reached 91.82%. In this post I’ll walk through what I built, the techniques that made the difference, and what I learned along the way.

The problem: teaching a model to see

CIFAR-10 contains 60,000 small colour images, each only 32 by 32 pixels, spread across ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship and truck. The images are small and often blurry, which makes the task harder than it sounds. A cat and a dog can look surprisingly similar at that resolution.

A regular fully connected neural network struggles here, because it treats every pixel as an independent input and ignores the structure of the image. CNNs solve this by sliding small filters across the image, so they can detect edges, textures and shapes anywhere in the picture. Early layers learn simple patterns, and deeper layers combine them into recognisable objects.

Setting up the data the right way

Before writing any model code, I split the data properly. The 50,000 training images were divided into 45,000 for training and 5,000 for validation, using a fixed random seed so the split is reproducible. The 10,000 test images stayed completely untouched until the very end.

This matters more than it might seem. The validation set is used to decide which version of the model to keep. The test set is used exactly once, to report an honest final number. If you tune your model on the test set, your reported accuracy becomes optimistic and meaningless.

The architecture

I used a VGG-style design, which is simple and effective:

  • Three convolutional blocks. Each block has two 3×3 convolution layers, each followed by Batch Normalization and a ReLU activation, then a max-pooling layer and Dropout. The channel count grows from 64 to 128 to 256 while the image size shrinks from 32 to 16 to 8 to 4 pixels.
  • A fully connected head. The final feature maps are flattened and passed through a 512-unit dense layer with Batch Normalization, ReLU and 50% Dropout, followed by a 10-unit output layer, one score per class.

I trained it with the cross-entropy loss and the AdamW optimizer, together with a OneCycle learning rate schedule, for 30 epochs with a batch size of 128. I also used mixed precision training, which made each epoch faster on the GPU.

Three lessons that made the difference

1. Data augmentation is a cheap and powerful upgrade

The task asked me to show that augmentation improves generalization, so I trained the same model twice: once on the plain images and once with random crops and random horizontal flips. Without augmentation the model reached 89.09% test accuracy. With augmentation it reached 91.82%, an improvement of 2.73 percentage points from changing only the input pipeline.

The reason is simple. A flipped or slightly shifted cat is still a cat, but to the model it is a brand new example. Augmentation effectively gives the network far more training data, so it memorizes less and generalizes better.

2. Batch Normalization and Dropout work well together

Batch Normalization keeps the values flowing through the network well scaled, which makes training faster and more stable and allows a higher learning rate. Dropout randomly switches off neurons during training, which forces the network not to depend on any single feature. I used a small dropout rate in early layers (0.1) and increased it with depth (0.2, 0.3, then 0.5 in the dense layer). This combination was the fastest route to a strong result, and it was more effective than simply making the network deeper.

3. Accuracy alone does not tell the whole story

A single accuracy number hides where a model fails. To dig deeper, I plotted a confusion matrix and looked at individual misclassified images. This showed which classes the model mixes up and why. Many of the errors involved classes that look alike at low resolution, which matches intuition: at 32 by 32 pixels, even humans sometimes hesitate. Looking at the mistakes directly gave me ideas for what to try next, such as stronger augmentation or a deeper network.

Monitoring training

I plotted training and validation accuracy and loss for every epoch. These curves are one of the most useful debugging tools in deep learning. If training accuracy keeps climbing while validation accuracy stalls, the model is overfitting. Comparing the curves of the augmented and non-augmented runs showed a smaller gap between training and validation performance with augmentation, which is exactly the behaviour we want.

Reproducibility

The task required that the reported accuracy be real and reproducible. I fixed the random seeds, saved the results to a JSON file, and generated the README and all charts directly from the notebook, so the numbers in the write-up always match what the code produced. Small run-to-run variations of a few tenths of a percent are normal on a GPU, but the overall result is stable.

What I would try next

With more time, I would experiment with residual connections as used in ResNet, stronger augmentation such as Cutout or MixUp, and learning rate tuning. Each of these is known to push CIFAR-10 accuracy higher, and I now have a solid baseline to compare against.

Final thoughts

This project taught me that good deep learning is less about exotic architectures and more about careful fundamentals: a clean data split, sensible regularization, honest evaluation and a habit of inspecting your model’s mistakes. Going from a basic CNN to over 91% accuracy came from a handful of well-chosen techniques, not from complexity.

The full code, training curves, confusion matrix and results are available on my GitHub: github.com/yeshi-rnj/ml9-cnn-image-classification.

Thank you to the Valentius Kryptix team for the hands-on learning experience.

YESHASHVI RANJAN Avatar

Leave a Reply

You May Love