This project implements ResNet-18 from scratch in PyTorch and trains it on the CIFAR-10 dataset to achieve high accuracy in image classification.
This repository provides a complete implementation of the ResNet-18 architecture, a deep residual network renowned for its simplicity and effectiveness in image classification tasks. The model is trained on the CIFAR-10 dataset, which contains 60,000 32x32 color images in 10 classes. The focus of this project is to build and train the ResNet-18 model from the ground up, achieving high accuracy, and exploring the learned feature space of the model.
- Model: Implement the ResNet-18 architecture from scratch in PyTorch.
- Task: Train the model on the CIFAR-10 dataset to classify images into one of 10 categories.
- Feature Exploration: Visualize and analyze the feature space using t-SNE and k-Nearest Neighbors (k-NN) algorithms.
Ensure you have the following dependencies installed before running the project:
- Python 3.6+: The programming language used for the project.
- PyTorch: The deep learning framework employed for building and training ResNet-18.
- Scikit-learn: For implementing the t-SNE algorithm and k-NN classifiers.
Install the required libraries via pip:
pip install torch scikit-learn
The ResNet-18 model, after training on the CIFAR-10 dataset, achieves the following accuracy:
Model | Accuracy |
---|---|
ResNet-18 | 90.71% |
Understanding the feature space learned by a deep network can provide insights into how the model discriminates between different classes. In this project, we explore the outputs of the penultimate layer (one layer before the final classification layer) using the following methods:
- t-SNE
- k-NN
The feature space refers to the high-dimensional space where the outputs of the neurons in the layer just before the final classification layer reside. Visualizing this space provides valuable insights into the model's internal representations.
t-SNE (t-distributed Stochastic Neighbor Embedding) is used to reduce the dimensionality of the feature space and project it into a 2D plane for visualization. This technique helps in understanding how well the model separates different classes in the feature space.
k-NN is applied to the feature space to explore the clustering of different classes. It helps in assessing the compactness and separability of the feature vectors generated by the model.