import torch.nn as nn import torch.nn.functional as F class BasicCNN(nn.Module): def __init__(self): super(BasicCNN, self).__init__() self.conv1 = nn.Conv2d(1, 32, kernel_size=3, padding=1) self.pool = nn.MaxPool2d(kernel_size=2, stride=2) self.conv2 = nn.Conv2d(32, 64, kernel_size=3, padding=1) self.fc1 = nn.Linear(64 * 7 * 7, 128) # After two pooling layers (28x28 -> 14x14 -> 7x7) self.fc2 = nn.Linear(128, 10) # 10 classes in FashionMNIST def forward(self, x): x = self.pool(F.relu(self.conv1(x))) x = self.pool(F.relu(self.conv2(x))) x = x.view(-1, 64 * 7 * 7) # Flatten the tensor x = F.relu(self.fc1(x)) x = self.fc2(x) return x