-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
29 lines (24 loc) · 832 Bytes
/
models.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
from torch import nn
from torch.cuda import amp
class SRCNN(nn.Module):
def __init__(self, num_channels=1):
super(SRCNN, self).__init__()
# Patch extraction and representation.
self.features = nn.Sequential(
nn.Conv2d(num_channels, 64, kernel_size=9, padding=9 // 2),
nn.ReLU(inplace=True)
)
# Non-linear mapping.
self.map = nn.Sequential(
nn.Conv2d(64, 32, kernel_size=5, padding=5 // 2),
nn.ReLU(inplace=True)
)
# Reconstruction image.
self.reconstruction = nn.Conv2d(
32, num_channels, kernel_size=5, padding=5 // 2)
@amp.autocast()
def forward(self, input):
out = self.features(input)
out = self.map(out)
out = self.reconstruction(out)
return out