Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CIFAR-10 Image Classifier (CNN)

A convolutional neural network built with PyTorch to classify images from the CIFAR-10 dataset into 10 categories.

Overview

This project implements a CNN from scratch to classify 32x32 color images into one of 10 classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck.

Model Architecture

  • 3 convolutional blocks (Conv2d → ReLU → MaxPool2d), with channel depth increasing 3 → 32 → 64 → 128
  • Flatten layer
  • 2 fully connected layers (2048 → 256 → 10)

Dataset

  • CIFAR-10, loaded via torchvision.datasets.CIFAR10
  • Preprocessing: images converted to tensors and normalized to a [-1, 1] range

Training

  • Loss function: Cross-Entropy Loss
  • Optimizer: Adam
  • Epochs: 10
  • Batch size: 64

Results

  • Final training loss: ~0.109
  • Test accuracy: 74.59%

Requirements

torch
torchvision

Usage

python train.py

This trains the model and saves the weights to cifar10_cnn.pth.

To load the saved model for inference:

model = CNN()
model.load_state_dict(torch.load("cifar10_cnn.pth"))
model.eval()

Notes

Training loss is noticeably lower than test accuracy would suggest, indicating some overfitting. Potential improvements include dropout, data augmentation, and batch normalization.

Author

Samir B K GitHub: github.com/Samir-BK