chore: README contents
Browse files- README.md +95 -0
- benchmarks/accuracy.png +3 -0
- benchmarks/architecture.png +3 -0
- benchmarks/classes.png +3 -0
- benchmarks/loss.png +3 -0
README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CNN with CIFAR-10
|
| 2 |
+
|
| 3 |
+
A PyTorch implementation of a Convolutional Neural Network (CNN) for image classification on the CIFAR-10 dataset, achieving **81.45% test accuracy**.
|
| 4 |
+
|
| 5 |
+
## Architecture
|
| 6 |
+
|
| 7 |
+

|
| 8 |
+
|
| 9 |
+
The CNN model consists of
|
| 10 |
+
### Convolutional Layers:
|
| 11 |
+
- **Conv1**: 3 → 32 channels, 3x3 kernel, padding=1
|
| 12 |
+
- **Conv2**: 32 → 64 channels, 3x3 kernel, padding=1
|
| 13 |
+
- **Conv3**: 64 → 128 channels, 3x3 kernel, padding=1
|
| 14 |
+
|
| 15 |
+
### Others
|
| 16 |
+
- **Batch Normalization** after each convolutional layer
|
| 17 |
+
- **MaxPooling2D** (2x2) for downsampling
|
| 18 |
+
- **ReLU** activation functions
|
| 19 |
+
- **Fully Connected Layers**: 2048 → 512 → 10
|
| 20 |
+
- **Dropout** (50%) for regularization
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
## Getting Started
|
| 24 |
+
|
| 25 |
+
### Prerequisites
|
| 26 |
+
- Python 3.12+
|
| 27 |
+
- PyTorch 2.7.1+
|
| 28 |
+
- torchvision 0.22.1+
|
| 29 |
+
|
| 30 |
+
> [!TIP]
|
| 31 |
+
> This project was developed with `uv`, so it is best to use `uv` for project management.
|
| 32 |
+
|
| 33 |
+
### Installation
|
| 34 |
+
|
| 35 |
+
1. **Clone the repository:**
|
| 36 |
+
```bash
|
| 37 |
+
git clone https://github.com/rahuletto/cnn
|
| 38 |
+
cd CNN
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
2. **Create virtual environment:**
|
| 42 |
+
```bash
|
| 43 |
+
python -m venv .venv
|
| 44 |
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
3. **Install dependencies:**
|
| 48 |
+
```bash
|
| 49 |
+
pip install -r requirements.txt
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
## Training Configuration
|
| 54 |
+
|
| 55 |
+
- **Optimizer**: Adam (lr=0.001)
|
| 56 |
+
- **Batch Size**: 64
|
| 57 |
+
- **Epochs**: 50
|
| 58 |
+
|
| 59 |
+
> Best model checkpoint was saved at epoch 49 with validation loss of 0.6553.
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
## Performance
|
| 63 |
+
|
| 64 |
+

|
| 65 |
+
Reaching 0.7227 in Train loss and 0.6557 in Validation loss at epoch 50
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
### Accuracy:
|
| 69 |
+
|
| 70 |
+
Total Accuracy: `81.45%`
|
| 71 |
+
- **Airplane**: `84.60%`
|
| 72 |
+
- **Automobile**: `93.20%`
|
| 73 |
+
- **Bird**: `76.90%`
|
| 74 |
+
- **Cat**: `69.70%`
|
| 75 |
+
- **Deer**: `77.20%`
|
| 76 |
+
- **Dog**: `64.00%`
|
| 77 |
+
- **Frog**: `89.30%`
|
| 78 |
+
- **Horse**: `82.10%`
|
| 79 |
+
- **Ship**: `89.60%`
|
| 80 |
+
- **Truck**: `87.90%`
|
| 81 |
+
|
| 82 |
+

|
| 83 |
+
|
| 84 |
+
---
|
| 85 |
+
|
| 86 |
+
## References
|
| 87 |
+
|
| 88 |
+
- [CIFAR-10 Dataset](https://www.cs.toronto.edu/~kriz/cifar.html)
|
| 89 |
+
- [PyTorch Documentation](https://pytorch.org/docs/)
|
| 90 |
+
- [Convolutional Neural Networks for Visual Recognition (CS231n)](http://cs231n.stanford.edu/)
|
| 91 |
+
- [Deep Learning Book - Ian Goodfellow](https://www.deeplearningbook.org/)
|
| 92 |
+
|
| 93 |
+
## License
|
| 94 |
+
|
| 95 |
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
benchmarks/accuracy.png
ADDED
|
Git LFS Details
|
benchmarks/architecture.png
ADDED
|
Git LFS Details
|
benchmarks/classes.png
ADDED
|
Git LFS Details
|
benchmarks/loss.png
ADDED
|
Git LFS Details
|