import torch import torch.nn as nn # Define the model class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.fc1 = nn.Linear(28*28, 128) # MNIST images are 28x28 self.fc2 = nn.Linear(128, 64) self.fc3 = nn.Linear(64, 10) # There are 10 classes (0 through 9) def forward(self, x): x = x.view(x.shape[0], -1) # Flatten the input x = torch.relu(self.fc1(x)) x = torch.relu(self.fc2(x)) return self.fc3(x)