chore: README contents
Browse files
README.md
CHANGED
|
@@ -41,7 +41,7 @@ The CNN model consists of
|
|
| 41 |
2. **Create virtual environment:**
|
| 42 |
```bash
|
| 43 |
python -m venv .venv
|
| 44 |
-
source .venv/bin/activate #
|
| 45 |
```
|
| 46 |
|
| 47 |
3. **Install dependencies:**
|
|
@@ -50,6 +50,35 @@ The CNN model consists of
|
|
| 50 |
```
|
| 51 |
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
## Training Configuration
|
| 54 |
|
| 55 |
- **Optimizer**: Adam (lr=0.001)
|
|
@@ -59,15 +88,18 @@ The CNN model consists of
|
|
| 59 |
> Best model checkpoint was saved at epoch 49 with validation loss of 0.6553.
|
| 60 |
|
| 61 |
|
| 62 |
-
#
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
|
|
|
|
|
|
|
| 67 |
|
| 68 |
### Accuracy:
|
| 69 |
|
| 70 |
Total Accuracy: `81.45%`
|
|
|
|
| 71 |
- **Airplane**: `84.60%`
|
| 72 |
- **Automobile**: `93.20%`
|
| 73 |
- **Bird**: `76.90%`
|
|
|
|
| 41 |
2. **Create virtual environment:**
|
| 42 |
```bash
|
| 43 |
python -m venv .venv
|
| 44 |
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
| 45 |
```
|
| 46 |
|
| 47 |
3. **Install dependencies:**
|
|
|
|
| 50 |
```
|
| 51 |
|
| 52 |
|
| 53 |
+
## Model Code
|
| 54 |
+
```py
|
| 55 |
+
class CNN(nn.Module):
|
| 56 |
+
def __init__(self):
|
| 57 |
+
super(CNN, self).__init__()
|
| 58 |
+
self.conv1 = nn.Conv2d(3, 32, 3, stride=1, padding=1) # 32x32 -> 16x16
|
| 59 |
+
self.bn1 = nn.BatchNorm2d(32)
|
| 60 |
+
self.conv2 = nn.Conv2d(32, 64, 3, stride=1, padding=1) # 16x16 -> 8x8
|
| 61 |
+
self.bn2 = nn.BatchNorm2d(64)
|
| 62 |
+
self.conv3 = nn.Conv2d(64, 128, 3, stride=1, padding=1) # 8x8 -> 4x4
|
| 63 |
+
self.bn3 = nn.BatchNorm2d(128)
|
| 64 |
+
self.pool = nn.MaxPool2d(stride=2, kernel_size=2)
|
| 65 |
+
self.fc1 = nn.Linear(128 * 4 * 4, 512)
|
| 66 |
+
self.fc2 = nn.Linear(512, 10)
|
| 67 |
+
self.dropout = nn.Dropout(0.5)
|
| 68 |
+
|
| 69 |
+
def forward(self, x):
|
| 70 |
+
x = self.pool(F.relu(self.bn1(self.conv1(x))))
|
| 71 |
+
x = self.pool(F.relu(self.bn2(self.conv2(x))))
|
| 72 |
+
x = self.pool(F.relu(self.bn3(self.conv3(x))))
|
| 73 |
+
x = x.view(x.size(0), -1)
|
| 74 |
+
x = self.dropout(x)
|
| 75 |
+
x = F.relu(self.fc1(x))
|
| 76 |
+
x = self.dropout(x)
|
| 77 |
+
x = self.fc2(x)
|
| 78 |
+
return x
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
|
| 82 |
## Training Configuration
|
| 83 |
|
| 84 |
- **Optimizer**: Adam (lr=0.001)
|
|
|
|
| 88 |
> Best model checkpoint was saved at epoch 49 with validation loss of 0.6553.
|
| 89 |
|
| 90 |
|
| 91 |
+
# Model
|
| 92 |
+
There are two CNN models in `cnn/` folder
|
| 93 |
+
- `model.pt`
|
| 94 |
+
- `model-old.pt`
|
| 95 |
|
| 96 |
+
`model.pt` was trained with `BatchNorm2d` to reach 81.45% accuracy in CIFAR-10 dataset
|
| 97 |
+
`model-old.pt` was trained without fine tuning which gets 75% accuracy in CIFAR-10 dataset
|
| 98 |
|
| 99 |
### Accuracy:
|
| 100 |
|
| 101 |
Total Accuracy: `81.45%`
|
| 102 |
+
|
| 103 |
- **Airplane**: `84.60%`
|
| 104 |
- **Automobile**: `93.20%`
|
| 105 |
- **Bird**: `76.90%`
|