def __init__(self, input_channel, pool_reduce_channel, conv1_channel, conv3_reduce_channel, conv3_channel, conv3_double_reduce_channel, conv3_double_channel_1_1, conv3_double_channel_1_2, conv3_double_channel_2): super(Inceptionv4_C, self).__init__() self.pool = nn.Sequential( nn.AvgPool2d(kernel_size=3, stride=1, padding=1), Conv2d(input_channel, pool_reduce_channel, kernel_size=1)) self.conv1 = Conv2d(input_channel, conv1_channel, kernel_size=1) self.conv3 = nn.Sequential( Conv2d(input_channel, conv3_reduce_channel, kernel_size=1), Concat_Separable_Conv2d(conv3_reduce_channel, conv3_channel, kernel_size=3, padding=1)) self.conv3_double = nn.Sequential( Conv2d(input_channel, conv3_double_reduce_channel, kernel_size=1), Separable_Conv2d(conv3_double_reduce_channel, conv3_double_channel_1_1, conv3_double_channel_1_2, kernel_size=3, padding=1), Concat_Separable_Conv2d(conv3_double_channel_1_2, conv3_double_channel_2, kernel_size=3, padding=1))
def __init__(self, input_channel, conv3_channel, conv3_double_reduce_channel, conv3_double_channel): super(Inceptionv4_reduction_B, self).__init__() self.pool = nn.MaxPool2d(3, 2) self.conv3 = nn.Sequential(Conv2d(input_channel, conv3_channel, 1), Conv2d(conv3_channel, conv3_channel, 3, 2)) self.conv3_double = nn.Sequential( Conv2d(input_channel, conv3_double_reduce_channel, 1), Separable_Conv2d(conv3_double_reduce_channel, conv3_double_reduce_channel, conv3_double_channel, 7, padding=3), Conv2d(conv3_double_channel, conv3_double_channel, 3, stride=2))
def __init__(self, input_channel, conv3_channel, conv3_double_reduce_channel, conv3_double_channel_1, conv3_double_channel_2): super(Inceptionv4_reduction_A, self).__init__() self.pool = nn.MaxPool2d(3, 2) self.conv3 = Conv2d(input_channel, conv3_channel, 3, 2) # n self.conv3_double = nn.Sequential( Conv2d(input_channel, conv3_double_reduce_channel, 1), # k Conv2d(conv3_double_reduce_channel, conv3_double_channel_1, 3, padding=1), # l Conv2d(conv3_double_channel_1, conv3_double_channel_2, 3, stride=2) # m )
def __init__(self): super(Inceptionv4_stem, self).__init__() self.stem1 = nn.Sequential( Conv2d(3, 32, 3, stride=2), Conv2d(32, 32, 3, stride=1), Conv2d(32, 64, 3, stride=1, padding=1), ) self.stem1_1 = nn.MaxPool2d(3, 2) self.stem1_2 = Conv2d(64, 96, 3, 2) self.stem2_1 = nn.Sequential( Conv2d(160, 64, 1), Conv2d(64, 96, 3), ) self.stem2_2 = nn.Sequential( Conv2d(160, 64, 1), Separable_Conv2d(64, 64, 64, 7, padding=3), Conv2d(64, 96, 3)) self.stem3_1 = nn.MaxPool2d(3, 2) self.stem3_2 = Conv2d(192, 192, 3, 2)
def __init__(self, num_classes, mode='train'): super(GoogLeNetv4, self).__init__() self.num_classes = num_classes self.mode = mode self.layers = nn.Sequential( Inceptionv4_stem(), Inceptionv4_A(384, 96, 96, 64, 96, 64, 96, 96), Inceptionv4_A(384, 96, 96, 64, 96, 64, 96, 96), Inceptionv4_A(384, 96, 96, 64, 96, 64, 96, 96), Inceptionv4_A(384, 96, 96, 64, 96, 64, 96, 96), Inceptionv4_reduction_A(384, 384, 192, 224, 256), Inceptionv4_B(1024, 128, 384, 192, 224, 256, 192, 224, 256), Inceptionv4_B(1024, 128, 384, 192, 224, 256, 192, 224, 256), Inceptionv4_B(1024, 128, 384, 192, 224, 256, 192, 224, 256), Inceptionv4_B(1024, 128, 384, 192, 224, 256, 192, 224, 256), Inceptionv4_B(1024, 128, 384, 192, 224, 256, 192, 224, 256), Inceptionv4_B(1024, 128, 384, 192, 224, 256, 192, 224, 256), Inceptionv4_B(1024, 128, 384, 192, 224, 256, 192, 224, 256), Inceptionv4_reduction_B(1024, 192, 256, 320), Inceptionv4_C(1536, 256, 256, 384, 256, 384, 448, 512, 256), Inceptionv4_C(1536, 256, 256, 384, 256, 384, 448, 512, 256), Inceptionv4_C(1536, 256, 256, 384, 256, 384, 448, 512, 256), nn.AvgPool2d(8, 1), nn.Dropout2d(0.2, inplace=True), Conv2d(1536, num_classes, kernel_size=1, output=True), Squeeze())