-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.py
32 lines (24 loc) · 1019 Bytes
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
class CATnDOGconv(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=(5,5), stride=2, padding=1)
self.conv2 = nn.Conv2d(in_channels=16, out_channels=32, kernel_size=(5,5), stride=2, padding=1)
self.conv3 = nn.Conv2d(in_channels=32, out_channels=64, kernel_size=(3,3), padding=1)
self.fc1 = nn.Linear(in_features=64*6*6, out_features=500)
self.fc2 = nn.Linear(in_features=500, out_features=50)
self.fc3 = nn.Linear(in_features=50, out_features=2)
def forward(self, X):
X = F.relu(self.conv1(X))
X = F.max_pool2d(X, 2)
X = F.relu(self.conv2(X))
X = F.max_pool2d(X, 2)
X = F.relu(self.conv3(X))
X = F.max_pool2d(X, 2)
X = X.view(X.shape[0], -1)
X = F.relu(self.fc1(X))
X = F.relu(self.fc2(X))
X = self.fc3(X)
return X