| 70 | # classification dataset: |
| 71 | |
| 72 | class MNISTNet(nn.Module): |
| 73 | def __init__(self): |
| 74 | super().__init__() |
| 75 | self.conv1 = nn.Conv2d(1, 32, 3, 1) |
| 76 | self.dropout1 = nn.Dropout(0.25) |
| 77 | self.conv2 = nn.Conv2d(32, 64, 3, 1) |
| 78 | self.fc1 = nn.Linear(9216, 128) |
| 79 | self.dropout2 = nn.Dropout(0.5) |
| 80 | self.fc2 = nn.Linear(128, 10) |
| 81 | |
| 82 | def forward(self, x): |
| 83 | x = self.conv1(x) |
| 84 | x = nn.functional.relu(x) |
| 85 | x = self.conv2(x) |
| 86 | x = nn.functional.relu(x) |
| 87 | x = nn.functional.max_pool2d(x, 2) |
| 88 | x = self.dropout1(x) |
| 89 | x = torch.flatten(x, 1) |
| 90 | x = self.fc1(x) |
| 91 | x = nn.functional.relu(x) |
| 92 | x = self.dropout2(x) |
| 93 | x = self.fc2(x) |
| 94 | return nn.functional.log_softmax(x, dim=1) |
| 95 | |
| 96 | ###################################################################### |
| 97 | # Define the Ray Serve deployment |