Views
No views yet
Try it out! https://huggingface.co/spaces/Rahuletto/CNN

[!TIP] This project was developed withuv, so it is best to useuvfor project management.
1git clone https://github.com/rahuletto/cnn
2cd CNN1python -m venv .venv
2source .venv/bin/activate # Windows: .venv\Scripts\activatepip install -r requirements.txtpython main.py1class CNN(nn.Module):
2 def __init__(self):
3 super(CNN, self).__init__()
4 self.conv1 = nn.Conv2d(3, 32, 3, stride=1, padding=1) # 32x32 -> 16x16
5 self.bn1 = nn.BatchNorm2d(32)
6 self.conv2 = nn.Conv2d(32, 64, 3, stride=1, padding=1) # 16x16 -> 8x8
7 self.bn2 = nn.BatchNorm2d(64)
8 self.conv3 = nn.Conv2d(64, 128, 3, stride=1, padding=1) # 8x8 -> 4x4
9 self.bn3 = nn.BatchNorm2d(128)
10 self.pool = nn.MaxPool2d(stride=2, kernel_size=2)
11 self.fc1 = nn.Linear(128 * 4 * 4, 512)
12 self.fc2 = nn.Linear(512, 10)
13 self.dropout = nn.Dropout(0.5)
14
15 def forward(self, x):
16 x = self.pool(F.relu(self.bn1(self.conv1(x))))
17 x = self.pool(F.relu(self.bn2(self.conv2(x))))
18 x = self.pool(F.relu(self.bn3(self.conv3(x))))
19 x = x.view(x.size(0), -1)
20 x = self.dropout(x)
21 x = F.relu(self.fc1(x))
22 x = self.dropout(x)
23 x = self.fc2(x)
24 return xBest model checkpoint was saved at epoch 49 with validation loss of 0.6553.
cnn/ foldermodel.ptmodel-old.ptmodel.pt was trained with BatchNorm2d to reach 81.45% accuracy in CIFAR-10 dataset
model-old.pt was trained without fine tuning which gets 75% accuracy in CIFAR-10 dataset81.45%84.60%93.20%76.90%69.70%77.20%64.00%89.30%82.10%89.60%87.90%