How can i increease the accusracy further

username: slay_official
cooked: <p>import torch<br>
import torch.nn as nn<br>
import torch.nn.functional as F<br>
import torch.optim as optim<br>
import torchvision<br>
import torchvision.transforms as transforms</p>
<p>class CustomCNN(nn.Module):<br>
def <strong>init</strong>(self):<br>
super(CustomCNN, self).<strong>init</strong>()<br>
self.conv1 = nn.Conv2d(in_channels=3, out_channels=32, kernel_size=3, stride=1, padding=1)<br>
self.pool = nn.MaxPool2d(kernel_size=2, stride=2, padding=0)<br>
self.conv2 = nn.Conv2d(in_channels=32, out_channels=64, kernel_size=3, stride=1, padding=1)<br>
self.fc1 = nn.Linear(64 * 8 * 8, 512)  # Assuming input size is 32x32<br>
self.fc2 = nn.Linear(512, 10)  # CIFAR-10 has 10 classes</p>
<pre><code>def forward(self, x):
    x = self.pool(F.relu(self.conv1(x)))  # Apply Conv1 + ReLU + Pooling
    x = self.pool(F.relu(self.conv2(x)))  # Apply Conv2 + ReLU + Pooling
    x = x.view(-1, 64 * 8 * 8)  # Flatten the tensor
    x = F.relu(self.fc1(x))     # Apply FC1 + ReLU
    x = self.fc2(x)             # Apply FC2
    return x
</code></pre>
<p>def train_model(net, trainloader, criterion, optimizer, num_epochs=10):<br>
net.train()  # Set the model to training mode<br>
for epoch in range(num_epochs):<br>
running_loss = 0.0<br>
for i, data in enumerate(trainloader, 0):<br>
inputs, labels = data<br>
optimizer.zero_grad()<br>
outputs = net(inputs)<br>
loss = criterion(outputs, labels)<br>
loss.backward()<br>
optimizer.step()<br>
running_loss += loss.item()<br>
if i % 100 == 99:  # Print every 100 mini-batches<br>
print(f’Epoch [{epoch + 1}/{num_epochs}], Step [{i + 1}], Loss: {running_loss / 100:.4f}')<br>
running_loss = 0.0<br>
print(‘Finished Training’)</p>
<p>def evaluate_model(net, testloader):<br>
net.eval()  # Set the model to evaluation mode<br>
correct = 0<br>
total = 0<br>
with torch.no_grad():<br>
for data in testloader:<br>
images, labels = data<br>
outputs = net(images)<br>
_, predicted = torch.max(outputs.data, 1)<br>
total += labels.size(0)<br>
correct += (predicted == labels).sum().item()<br>
accuracy = 100 * correct / total<br>
print(f’Accuracy of the network on the 10000 test images: {accuracy:.2f}%')<br>
return accuracy</p>
<p>if <strong>name</strong> == ‘<strong>main</strong>’:<br>
transform = transforms.Compose([<br>
transforms.ToTensor(),<br>
transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010))<br>
])</p>
<pre><code>trainset = torchvision.datasets.CIFAR10(root='./data', train=True, download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=300, shuffle=True, num_workers=2)

testset = torchvision.datasets.CIFAR10(root='./data', train=False, download=True, transform=transform)
testloader = torch.utils.data.DataLoader(testset, batch_size=100, shuffle=False, num_workers=2)

net = CustomCNN()
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(net.parameters(), lr=0.001,)

train_model(net, trainloader, criterion, optimizer, num_epochs=10)
test_accuracy = evaluate_model(net, testloader)
</code></pre>
<p>‘’’<br>
Accuracy of the network on the 10000 test images: 72.54%<br>
i am getting this accuracy i tried increasing learning rate to 0.02,0.03 … and increased the number of channels too but still the range is between 70-75 its not improving.<br>
*i am working on CIFAR-10 DATASET</p>

username: Preston_Brubaker
cooked: <p>I recommend using a deeper network, using batch normalization between layers.</p>