import torch
import torch.nn as nn
import torch.nn.functional as F

class TinyCNN(nn.Module):
    def __init__(self, num_classes=100):
        super(TinyCNN, self).__init__()
        # A single convolutional layer with a small number of filters
        self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)

        # A single fully connected layer
        self.fc1 = nn.Linear(8 * 16 * 16, num_classes)

    def forward(self, x):
        # Apply the convolution, followed by ReLU and a pooling layer
        x = F.relu(self.conv1(x))
        x = F.max_pool2d(x, 2)

        # Flatten the tensor for the fully connected layer
        x = x.view(-1, 8 * 16 * 16)

        # Output layer directly maps to the number of classes
        x = self.fc1(x)
        return x
