Welcome to a comprehensive tutorial on the Fashion MNIST dataset using PyTorch. Fashion MNIST is a dataset of 60,000 28x28 grayscale images of 10 fashion categories, along with a test set of 10,000 images.
The Fashion MNIST dataset is a collection of grayscale images of 10 fashion categories, each of size 28x28 pixels. It's used as a drop-in replacement for the classic MNIST dataset. It serves as a more challenging classification problem than the regular MNIST digit dataset due to the similarities in clothing items.
Each image in the dataset corresponds to a label from 0-9, representing the ten categories:
| Label | Description |
|---|---|
| 0 | T-shirt/top |
| 1 | Trouser |
| 2 | Pullover |
| 3 | Dress |
| 4 | Coat |
| 5 | Sandal |
| 6 | Shirt |
| 7 | Sneaker |
| 8 | Bag |
| 9 | Ankle boot |
- PyTorch Tutorial: Fashion MNIST with Convolutional Neural Networks (CNNs)
- Prerequisites
- Setup and Installation
- Understanding the Fashion MNIST Dataset
- Data Loading and Preprocessing
- Understanding PyTorch Utilities
- Convolutional Neural Networks (CNNs)
- Training and Evaluation
- Understanding Optimizers and Loss Functions
- Training Loop (Explained)
- Evaluation
- Advanced Topics: Regularization with Dropout
- Understanding the Role of
F.log_softmax - Training
- Logging and Observing the Loss During Training
- Reusing the Evaluation Code and The Importance of Testing on a Validation Set
- Advanced Topics: Data Augmentation
- Conclusion
- References and Acknowledgments
- Exercises for Practice
- Additional Resources
- Feedback
- Exercise Solutions
Before diving into the tutorial, ensure you have the following prerequisites installed and set up:
- Python: This tutorial requires Python 3.x. Python is the primary language we'll be using.
- PyTorch & torchvision: PyTorch is an open-source machine learning library, and torchvision offers datasets and models for computer vision.
- Jupyter Notebook: The interactive environment where this tutorial is presented.
- NumPy: A library for numerical operations in Python.
- scikit-learn: Machine learning library in Python. We'll use it for performance metrics.
- Seaborn & Matplotlib: Visualization libraries in Python.
- CUDA (Optional): If you have a compatible NVIDIA GPU, you can install CUDA for GPU acceleration with PyTorch.
This tutorial was meticulously crafted by Muhammad Junaid Ali Asif Raja for a seminar/workshop held on 27th October 2023. The main aim is to provide a comprehensive understanding of implementing CNNs using PyTorch, targeting both beginners and intermediate learners.
Follow these steps to get started with the tutorial:
git clone https://github.com/junaidaliop/pytorch-fashionMNIST-tutorial.git
cd pytorch-fashionMNIST-tutorialUse the provided PyTorchTutorial.xml file to set up the Conda environment with all required dependencies:
conda env create -f PyTorchTutorial.xmlActivate the environment:
conda activate PyTorchTutorialjupyter notebookNavigate to the pytorch_fashion_mnist_tutorial.ipynb file in the Jupyter Notebook interface, and you're ready to dive into the tutorial!
Special thanks to Dr. Naveed Ishtiaq Chaudhary for presenting me with the opportunity.