IR-B模块*10:输入17*17*896,输出17*17*896.
class Inception_ResNet_B(nn.Module):
def __init__(self, input):
super(Inception_ResNet_B, self).__init__()
self.conv1 = conv1x1(in_planes =input,out_channels=128,stride=1, padding=0)
self.conv1x7 = nn.Conv2d(in_channels=128,out_channels=128,kernel_size=(1,7), padding=(0,3))
self.conv7x1 = nn.Conv2d(in_channels=128, out_channels=128,kernel_size=(7,1), padding=(3,0))
self.line = nn.Conv2d(256, 896, 1, stride=1, padding=0, bias=True)
self.relu = nn.ReLU()
def forward(self, x):
c1 = self.conv1(x)
# print("c1",c1.shape)
c2 = self.conv1(x)
# print("c2", c2.shape)
c2_1 = self.conv1x7(c2)
# print("c2_1", c2_1.shape)
c2_1 = self.relu(c2_1)
c2_2 = self.conv7x1(c2_1)
# print("c2_2", c2_2.shape)
c2_2 = self.relu(c2_2)
cat = torch.cat([c1, c2_2], dim=1)
line = self.line(cat)
out =x+line
out = self.relu(out)
# print("out", out.shape)
return out
Reduction-B模块:输入17*17*896,输出8*8*1792.
class Reduction_B(nn.Module):
def __init__(self, input):
super(Reduction_B, self).__init__()
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
self.conv1 = conv1x1(in_planes=input, out_channels=256, padding=1)
self.conv2 = conv3x3(in_planes=256, out_channels=384, stride=2, padding=0)
self.conv3 = conv3x3(in_planes=256, out_channels=256,stride=2, padding=0)
self.conv4 = conv3x3(in_planes=256, out_channels=256, padding=1)
self.conv5 = conv3x3(in_planes=256, out_channels=256, stride=2, padding=0)
def forward(self, x):
c1 = self.maxpool(x)
# print("c1", c1.shape)
c2 = self.conv1(x)
# print("c2", c2.shape)
c3 = self.conv1(x)
# print("c3", c3.shape)
c4 = self.conv1(x)
# print("c4", c4.shape)
c2_1 = self.conv2(c2)
# print("cc2_1", c2_1.shape)
c3_1 = self.conv3(c3)
# print("c3_1", c3_1.shape)
c4_1 = self.conv4(c4)
# print("c4_1", c4_1.shape)
c4_2 = self.conv5(c4_1)
# print("c4_2", c4_2.shape)
cat = torch.cat([c1, c2_1, c3_1,c4_2], dim=1)
# print("cat", cat.shape)
return cat
IR-C模块*5:输入8*8*1792,输出8*8*1792.
class Inception_ResNet_C(nn.Module):
def __init__(self, input):
super(Inception_ResNet_C, self).__init__()
self.conv1 = conv1x1(in_planes=input, out_channels=192, stride=1, padding=0)
self.conv1x3 = nn.Conv2d(in_channels=192, out_channels=192, kernel_size=(1, 3), padding=(0,1))
self.conv3x1 = nn.Conv2d(in_channels=192, out_channels=192, kernel_size=(3, 1), padding=(1,0))
self.line = nn.Conv2d(384, 1792, 1, stride=1, padding=0, bias=True)
self.relu = nn.ReLU()
def forward(self, x):
c1 = self.conv1(x)
# print("x", x.shape)
# print("c1",c1.shape)
c2 = self.conv1(x)
# print("c2", c2.shape)
c2_1 = self.conv1x3(c2)
# print("c2_1", c2_1.shape)
c2_1 = sel