-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
27 lines (24 loc) · 928 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
from torch import nn
class AutoEncoder(nn.Module):
def __init__(self):
super(AutoEncoder, self).__init__()
self.encoder = nn.Sequential(
nn.Conv2d(1, 16, kernel_size=3, padding=1), # 16, 20, 20
nn.ReLU(True),
nn.MaxPool2d(2), # 16, 10, 10
nn.Conv2d(16, 8, kernel_size=3, padding=1),
nn.ReLU(True),
nn.MaxPool2d(2), # 8, 5, 5
)
self.decoder = nn.Sequential(
nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True),
nn.Conv2d(8, 16, kernel_size=1, stride=1), # 16, 10, 10
nn.ReLU(True),
nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True),
nn.Conv2d(16, 1, kernel_size=1, stride=1), # 1, 20, 20
nn.ReLU(True),
)
def forward(self, x):
x = self.encoder(x)
x = self.decoder(x)
return x