import torch.nn as nn class SimpleCNN(nn.Module): def __init__(self): super(SimpleCNN, self).__init__() self.conv1 = nn.Conv2d(3, 16, kernel_size=3, padding=1) self.relu1 = nn.ReLU() self.pool1 = nn.MaxPool2d(2, 2) self.conv2 = nn.Conv2d(16, 16, kernel_size=3, padding=1) self.relu2 = nn.ReLU() self.pool2 = nn.MaxPool2d(2, 2) self.conv3 = nn.Conv2d(16, 16, kernel_size=3, padding=1) self.relu3 = nn.ReLU() self.pool3 = nn.MaxPool2d(2, 2) self.conv4 = nn.Conv2d(16, 32, kernel_size=3, padding=1) self.relu4 = nn.ReLU() self.pool4 = nn.MaxPool2d(2, 2) self.fc1 = nn.Linear(32 * 2 * 2, 256) self.fc2 = nn.Linear(256, 10) def forward(self, x): x = self.pool1(self.relu1(self.conv1(x))) x = self.pool2(self.relu2(self.conv2(x))) x = self.pool3(self.relu3(self.conv3(x))) x = self.pool4(self.relu4(self.conv4(x))) x = x.view(-1, 32 * 2 * 2) x = self.relu4(self.fc1(x)) x = self.fc2(x) return x