| 135 | |
| 136 | # PyTorch models inherit from torch.nn.Module |
| 137 | class GarmentClassifier(nn.Module): |
| 138 | def __init__(self): |
| 139 | super().__init__() |
| 140 | self.conv1 = nn.Conv2d(1, 6, 5) |
| 141 | self.pool = nn.MaxPool2d(2, 2) |
| 142 | self.conv2 = nn.Conv2d(6, 16, 5) |
| 143 | self.fc1 = nn.Linear(16 * 4 * 4, 120) |
| 144 | self.fc2 = nn.Linear(120, 84) |
| 145 | self.fc3 = nn.Linear(84, 10) |
| 146 | |
| 147 | def forward(self, x): |
| 148 | x = self.pool(F.relu(self.conv1(x))) |
| 149 | x = self.pool(F.relu(self.conv2(x))) |
| 150 | x = x.view(-1, 16 * 4 * 4) |
| 151 | x = F.relu(self.fc1(x)) |
| 152 | x = F.relu(self.fc2(x)) |
| 153 | x = self.fc3(x) |
| 154 | return x |
| 155 | |
| 156 | |
| 157 | model = GarmentClassifier() |