A deep learning project that implements a Convolutional Neural Network (CNN) to classify Fashion-MNIST images into 10 different clothing categories.
The Fashion-MNIST dataset consists of 70,000 grayscale images of clothing items:
- Training Set: 60,000 images
- Test Set: 10,000 images
- Image Size: 28x28 pixels
- Classes: 10 clothing categories
- T-shirt/top
- Trouser
- Pullover
- Dress
- Coat
- Sandal
- Shirt
- Sneaker
- Bag
- Ankle boot
The CNN classifier consists of:
- 2 Convolutional Blocks
- Conv2D → ReLU → Conv2D → ReLU → MaxPool2D
- Fully Connected Classifier
- Flatten → Linear layer
Total Parameters: ~7,850
fashion-mnist-classifier/
│
├── Fashion-MNIST_Complete.ipynb
│
├── models/
│ ├── fashion_mnist_best_model.pth
│ └── fashion_mnist_final_model.pth
│
├── outputs/
│ ├── visualizations/
│ │ ├── class_distribution.png
│ │ ├── sample_images.png
│ │ ├── training_history.png
│ │ ├── confusion_matrix.png
│ │ ├── sample_predictions.png
│ │ └── per_class_accuracy.png
│ └── classification_report.txt
│
├── data/
│ └── FashionMNIST/
│
├── README.md
├── requirements.txt
└── .gitignore
Open and run the Jupyter notebook:
jupyter notebook Fashion-MNIST_Complete.ipynb
Run all cells sequentially to:
- Load and explore the dataset
- Create data loaders
- Define and initialize the model
- Train the model (10 epochs by default)
- Generate visualizations and evaluation metrics
- Training Accuracy: ~95-96%
- Test Accuracy: ~90-91%
- Best Model: Automatically saved during training
The model shows steady improvement over 10 epochs with minimal overfitting.
Shows strong classification performance across all categories with some confusion between similar items (e.g., T-shirt vs Shirt, Pullover vs Coat).
- Best performing: Trousers, Bags, Ankle boots (>90%)
- Most challenging: Shirts, T-shirts, Pullovers (80-85%)
- ✅ Complete data exploration and visualization
- ✅ CNN architecture with multiple convolutional layers
- ✅ Training with progress tracking
- ✅ Automatic best model checkpointing
- ✅ Comprehensive evaluation metrics
- ✅ Confusion matrix analysis
- ✅ Per-class accuracy breakdown
- ✅ Sample prediction visualization
- ✅ Organized output structure
# In the notebook, modify these values: BATCH_SIZE = 32 # Batch size for training epochs = 10 # Number of training epochs learning_rate = 0.001 # Adam optimizer learning rate hidden_units = 10 # Number of hidden units in conv layers
Simply change the epochs variable in the training loop cell.
All visualizations are automatically saved to outputs/visualizations/:
- Class Distribution - Bar chart showing data balance
- Sample Images - Grid of random training samples
- Training History - Loss and accuracy curves
- Confusion Matrix - Heatmap of predictions vs true labels
- Sample Predictions - 16 test predictions with confidence scores
- Per-Class Accuracy - Color-coded accuracy by category
- Clone the repository
git clone https://github.com/yourusername/fashion-mnist-classifier.git
cd fashion-mnist-classifier- Install required packages
pip install -r requirements.txt