submodule.py
1.
1
3
384
1248
def convbn(in_planes, out_planes, kernel_size, stride, pad, dilation):
return nn.Sequential(nn.Conv2d(in_planes, out_planes, kernel_size=kernel_size, stride=stride, padding=dilation if dilation > 1 else pad, dilation = dilation, bias=False),
nn.BatchNorm2d(out_planes))
class feature_extraction(nn.Module):
def __init__(self):
print('feature_extraction 123')
super(feature_extraction, self).__init__()
self.inplanes = 32
self.firstconv = nn.Sequential(convbn(3, 32, 3, 2, 1, 1), #下采样,缩小一倍。w,h各除以2.filter num:32。
nn.ReLU(inplace=True),
convbn(32, 32, 3, 1, 1, 1),
nn.ReLU(inplace=True),
convbn(32, 32, 3, 1, 1, 1),
nn.ReLU(inplace=True))
对应下面。
def forward(self, x):
output = self.firstconv(x)
print('submodule firstconv:')
print(output.size()[0])
print(output.size()[1])
print(output.size()[2])
print(output.size()[3])
submodule firstconv:
1
32
192
624
2.
self.lastconv = nn.Sequential(convbn(320, 128, 3, 1, 1, 1),
nn.ReLU(inplace=True),
nn.Conv2d(128, 32, kernel_size=1, padding=0, stride = 1, bias=False))
output_feature = torch.cat((output_raw, output_skip, output_branch4, output_branch3, output_branch2, output_branch1),
#output_branch4, output_branch3, output_branch2, output_branch1 第2个通道分别是32,output_raw是64,output_skip是128。其