-
Notifications
You must be signed in to change notification settings - Fork 8
/
models_resblock_v2.py
53 lines (36 loc) · 1.15 KB
/
models_resblock_v2.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import torch
import torch.nn as nn
from architecture.ResidualFeat import Res2Net
from architecture.netunit import *
import common
_NORM_BONE = False
class SSI_RES_UNET(nn.Module):
def __init__(self, in_ch=28, out_ch=28, conv=common.default_conv):
super(SSI_RES_UNET, self).__init__()
n_resblocks = 16
n_feats = 64
kernel_size = 3
scale = 1
act = nn.ReLU(True)
# define head module
m_head = [conv(in_ch, n_feats, kernel_size)]
# define body module
m_body = [
common.ResBlock(
conv, n_feats, kernel_size, act=act, res_scale= 1
) for _ in range(n_resblocks)
]
m_body.append(conv(n_feats, n_feats, kernel_size))
# define tail module
m_tail = [conv(n_feats, out_ch, kernel_size)]
self.head = nn.Sequential(*m_head)
self.body = nn.Sequential(*m_body)
self.tail = nn.Sequential(*m_tail)
def forward(self, x):
# x = self.sub_mean(x)
x = self.head(x)
res = self.body(x)
res += x
x = self.tail(res)
# x = self.add_mean(x)
return x