def __init__(self, n_classes):
        self.in_size = (299, 299)
        self.n_classes = n_classes
        super(Inception_Resnet_v2, self).__init__()
        with self.init_scope():
            self.Stem = Stem(3)

            for i in range(1, 11):
                self.add_link('Inc_A_{}'.format(i),
                              Inception_Resnet_A(384, scale=0.17))

            self.Red_A = Reduction_A(384, 256, 256, 384, 384)

            for i in range(1, 21):
                self.add_link('Inc_B_{}'.format(i),
                              Inception_Resnet_B(1152, scale=0.1))

            self.Red_B = Reduction_B(1152)

            for i in range(1, 10):
                self.add_link('Inc_C_{}'.format(i),
                              Inception_Resnet_C(2144, scale=0.2))
            self.add_link('Inc_C_10', Inception_Resnet_C(2144, scale=1.0))

            self.convbn = ConvBN(2144, 1536, ksize=1, stride=1, pad=0)
            self.fc = L.Linear(1536, self.n_classes)
    def __init__(self, n_classes):
        self.in_size = (299, 299)
        self.n_classes = n_classes
        super(Inception_Resnet_v1, self).__init__()
        with self.init_scope():
            self.Stem = Stem(3)

            for i in range(1, 6):
                self.add_link('Inc_A_{}'.format(i),
                              Inception_Resnet_A(256, scale=0.17))

            self.Red_A = Reduction_A(256, 192, 192, 256, 384)

            for i in range(1, 11):
                self.add_link('Inc_B_{}'.format(i),
                              Inception_Resnet_B(896, scale=0.1))

            self.Red_B = Reduction_B(896)

            for i in range(1, 5):
                self.add_link('Inc_C_{}'.format(i),
                              Inception_Resnet_C(1792, scale=0.2))
            self.add_link('Inc_C_5', Inception_Resnet_C(1792, scale=1.))

            self.convbn = ConvBN(1792, 1536, ksize=1, stride=1, pad=0)

            self.fc = L.Linear(1536, self.n_classes)
示例#3
0
 def __init__(self, ch, scale):
     super(Inception_Resnet_C, self).__init__()
     self.scale = scale
     initialW = initializers.GlorotNormal()
     with self.init_scope():
         self.convbn1 = ConvBN(ch, 192, ksize=1, stride=1,
                               initialW=initialW, pad=0)
         
         self.convbn2_1 = ConvBN(ch, 192, ksize=1, stride=1,
                                 initialW=initialW, pad=0)
         self.convbn2_2 = ConvBN(192, 192, ksize=(1, 3), stride=1,
                                 initialW=initialW, pad=(0, 1))
         self.convbn2_3 = ConvBN(192, 192, ksize=(3, 1), stride=1,
                                 initialW=initialW, pad=(1, 0))
         
         self.conv3 = L.Convolution2D(384, ch, ksize=1, stride=1,
                                      initialW=initialW, pad=0)
示例#4
0
    def __init__(self, ch, scale=1.):
        super(Inception_Resnet_B, self).__init__()
        self.scale = scale
        initialW = initializers.GlorotNormal()
        with self.init_scope():
            self.convbn1 = ConvBN(ch, 128, ksize=1, stride=1,
                                  initialW=initialW, pad=0)
            
            self.convbn2_1 = ConvBN(ch, 128, ksize=1, stride=1,
                                    initialW=initialW, pad=0)
            self.convbn2_2 = ConvBN(128, 128, ksize=(1, 7), stride=1,
                                    initialW=initialW, pad=(0, 3))

            self.convbn2_3 = ConvBN(128, 128, ksize=(7, 1), stride=1,
                                    initialW=initialW, pad=(3, 0))
            
            self.conv3 = L.Convolution2D(256, ch, ksize=1, stride=1,
                                         initialW=initialW, pad=0)
示例#5
0
    def __init__(self, ch):
        super(Inception_A, self).__init__()
        initialW = initializers.GlorotNormal()
        with self.init_scope():
            self.convbn1 = ConvBN(ch,
                                  96,
                                  ksize=1,
                                  stride=1,
                                  initialW=initialW,
                                  pad=0)

            self.convbn2_1 = ConvBN(ch,
                                    96,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)

            self.convbn3_1 = ConvBN(ch,
                                    64,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn3_2 = ConvBN(64,
                                    96,
                                    ksize=3,
                                    stride=1,
                                    initialW=initialW,
                                    pad=1)

            self.convbn4_1 = ConvBN(ch,
                                    64,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn4_2 = ConvBN(64,
                                    96,
                                    ksize=3,
                                    stride=1,
                                    initialW=initialW,
                                    pad=1)
            self.convbn4_3 = ConvBN(96,
                                    96,
                                    ksize=3,
                                    stride=1,
                                    initialW=initialW,
                                    pad=1)
    def __init__(self, ch):
        super(Reduction_B, self).__init__()
        initialW = initializers.GlorotNormal()
        with self.init_scope():
            self.convbn2_1 = ConvBN(ch,
                                    256,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn2_2 = ConvBN(256,
                                    384,
                                    ksize=3,
                                    stride=2,
                                    initialW=initialW,
                                    pad=0)

            self.convbn3_1 = ConvBN(ch,
                                    256,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn3_2 = ConvBN(256,
                                    288,
                                    ksize=3,
                                    stride=2,
                                    initialW=initialW,
                                    pad=0)

            self.convbn4_1 = ConvBN(ch,
                                    256,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn4_2 = ConvBN(256,
                                    288,
                                    ksize=3,
                                    stride=1,
                                    initialW=initialW,
                                    pad=1)

            self.convbn4_3 = ConvBN(288,
                                    320,
                                    ksize=3,
                                    stride=2,
                                    initialW=initialW,
                                    pad=0)
    def __init__(self, ch, scale=1.0):
        super(Inception_Resnet_A, self).__init__()
        self.scale = scale
        initialW = initializers.GlorotNormal()
        with self.init_scope():
            self.convbn1 = ConvBN(ch,
                                  32,
                                  ksize=1,
                                  stride=1,
                                  initialW=initialW,
                                  pad=0)

            self.convbn2_1 = ConvBN(ch,
                                    32,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn2_2 = ConvBN(32,
                                    32,
                                    ksize=3,
                                    stride=1,
                                    initialW=initialW,
                                    pad=1)

            self.convbn3_1 = ConvBN(ch,
                                    32,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn3_2 = ConvBN(32,
                                    48,
                                    ksize=3,
                                    stride=1,
                                    initialW=initialW,
                                    pad=1)
            self.convbn3_3 = ConvBN(48,
                                    64,
                                    ksize=3,
                                    stride=1,
                                    initialW=initialW,
                                    pad=1)

            self.conv4 = L.Convolution2D(128,
                                         ch,
                                         ksize=1,
                                         stride=1,
                                         initialW=initialW,
                                         pad=0)
示例#8
0
 def __init__(self, ch):
     super(Stem, self).__init__()
     initialW = initializers.GlorotNormal()
     with self.init_scope():
         self.convbn1 = ConvBN(ch, 32, ksize=3, stride=2,
                               initialW=initialW, pad=0)
         self.convbn2 = ConvBN(32, 32, ksize=3, stride=1,
                               initialW=initialW, pad=0)
         self.convbn3 = ConvBN(32, 64, ksize=3, stride=1,
                               initialW=initialW, pad=1)
         self.convbn4 = ConvBN(64, 80, ksize=1, stride=1,
                               initialW=initialW, pad=0)
         self.convbn5 = ConvBN(80, 192, ksize=3, stride=1,
                               initialW=initialW, pad=0)
         self.convbn6 = ConvBN(192, 256, ksize=3, stride=2,
                               initialW=initialW, pad=0)
示例#9
0
    def __init__(self, ch):
        super(Reduction_B, self).__init__()
        initialW = initializers.GlorotNormal()
        with self.init_scope():
            self.convbn2_1 = ConvBN(ch,
                                    192,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn2_2 = ConvBN(192,
                                    192,
                                    ksize=3,
                                    stride=2,
                                    initialW=initialW,
                                    pad=0)

            self.convbn3_1 = ConvBN(ch,
                                    256,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn3_2 = ConvBN(256,
                                    256,
                                    ksize=(1, 7),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(0, 3))
            self.convbn3_3 = ConvBN(256,
                                    320,
                                    ksize=(7, 1),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(3, 0))
            self.convbn3_4 = ConvBN(320,
                                    320,
                                    ksize=3,
                                    stride=2,
                                    initialW=initialW,
                                    pad=0)
示例#10
0
    def __init__(self, ch):
        super(Stem, self).__init__()
        initialW = initializers.GlorotNormal()
        with self.init_scope():
            self.convbn1 = ConvBN(ch,
                                  32,
                                  ksize=3,
                                  stride=2,
                                  initialW=initialW,
                                  pad=0)
            self.convbn2 = ConvBN(32,
                                  32,
                                  ksize=3,
                                  stride=1,
                                  initialW=initialW,
                                  pad=0)
            self.convbn3 = ConvBN(32,
                                  64,
                                  ksize=3,
                                  stride=1,
                                  initialW=initialW,
                                  pad=1)
            self.convbn4 = ConvBN(64,
                                  96,
                                  ksize=3,
                                  stride=2,
                                  initialW=initialW,
                                  pad=0)

            self.convbn5_1x1_1 = ConvBN(160,
                                        64,
                                        ksize=1,
                                        stride=1,
                                        initialW=initialW,
                                        pad=0)

            self.convbn5_7x1 = ConvBN(64,
                                      64,
                                      ksize=(7, 1),
                                      stride=1,
                                      initialW=initialW,
                                      pad=(3, 0))

            self.convbn5_1x7 = ConvBN(64,
                                      64,
                                      ksize=(1, 7),
                                      stride=1,
                                      initialW=initialW,
                                      pad=(0, 3))
            self.convbn5_3x3_1 = ConvBN(64,
                                        96,
                                        ksize=3,
                                        stride=1,
                                        initialW=initialW,
                                        pad=0)

            self.convbn5_1x1_2 = ConvBN(160,
                                        64,
                                        ksize=1,
                                        stride=1,
                                        initialW=initialW,
                                        pad=0)
            self.convbn5_3x3_2 = ConvBN(64,
                                        96,
                                        ksize=3,
                                        stride=1,
                                        initialW=initialW,
                                        pad=0)

            self.convbn6 = ConvBN(192,
                                  192,
                                  ksize=3,
                                  stride=2,
                                  initialW=initialW,
                                  pad=0)
示例#11
0
    def __init__(self, ch):
        super(Inception_C, self).__init__()
        initialW = initializers.GlorotNormal()
        with self.init_scope():
            self.convbn1 = ConvBN(ch,
                                  256,
                                  ksize=1,
                                  stride=1,
                                  initialW=initialW,
                                  pad=0)

            self.convbn2_1 = ConvBN(ch,
                                    256,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)

            self.convbn3_1 = ConvBN(ch,
                                    384,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn3_2_1 = ConvBN(384,
                                      256,
                                      ksize=(1, 3),
                                      stride=1,
                                      initialW=initialW,
                                      pad=(0, 1))
            self.convbn3_2_2 = ConvBN(384,
                                      256,
                                      ksize=(3, 1),
                                      stride=1,
                                      initialW=initialW,
                                      pad=(1, 0))

            self.convbn4_1 = ConvBN(ch,
                                    384,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn4_2 = ConvBN(384,
                                    448,
                                    ksize=(1, 3),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(0, 1))
            self.convbn4_3 = ConvBN(448,
                                    512,
                                    ksize=(3, 1),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(1, 0))
            self.convbn4_4_1 = ConvBN(512,
                                      256,
                                      ksize=(3, 1),
                                      stride=1,
                                      initialW=initialW,
                                      pad=(1, 0))
            self.convbn4_4_2 = ConvBN(512,
                                      256,
                                      ksize=(1, 3),
                                      stride=1,
                                      initialW=initialW,
                                      pad=(0, 1))
示例#12
0
    def __init__(self, ch):
        super(Inception_B, self).__init__()
        initialW = initializers.GlorotNormal()
        with self.init_scope():
            self.convbn1 = ConvBN(ch,
                                  128,
                                  ksize=1,
                                  stride=1,
                                  initialW=initialW,
                                  pad=0)

            self.convbn2_1 = ConvBN(ch,
                                    384,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)

            self.convbn3_1 = ConvBN(ch,
                                    192,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn3_2 = ConvBN(192,
                                    224,
                                    ksize=(1, 7),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(0, 3))
            self.convbn3_3 = ConvBN(224,
                                    256,
                                    ksize=(7, 1),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(3, 0))

            self.convbn4_1 = ConvBN(ch,
                                    192,
                                    ksize=1,
                                    stride=1,
                                    initialW=initialW,
                                    pad=0)
            self.convbn4_2 = ConvBN(192,
                                    192,
                                    ksize=(1, 7),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(0, 3))
            self.convbn4_3 = ConvBN(192,
                                    224,
                                    ksize=(7, 1),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(3, 0))
            self.convbn4_4 = ConvBN(224,
                                    224,
                                    ksize=(1, 7),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(0, 3))
            self.convbn4_5 = ConvBN(224,
                                    256,
                                    ksize=(7, 1),
                                    stride=1,
                                    initialW=initialW,
                                    pad=(3, 0))