File size: 652 Bytes
c9e0c1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from torch import nn
import torch.nn.functional as F

class ShapeClassifier(nn.Module):
    def __init__(self, num_classes):
        super(ShapeClassifier, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, padding=1)
        self.pool = nn.MaxPool2d(kernel_size=2, stride=2)
        self.fc1 = nn.Linear(16 * 64 * 64, 128)
        self.fc2 = nn.Linear(128, num_classes)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = x.view(-1, 16 * 64 * 64)  # Adjust the dimensions based on your input image size
        x = F.relu(self.fc1(x))
        x = self.fc2(x)
        return x