def __init__(self, num_classes, block, layers, cardinality): self.inplanes = 128 self.cardinality = cardinality super(ResNeXt, self).__init__() self.conv1 = rm.Conv2d(64, filter=7, stride=2, padding=3, ignore_bias=True) self.bn1 = rm.BatchNormalize(epsilon=0.00001, mode='feature') self.relu = rm.Relu() self.maxpool = rm.MaxPool2d(filter=3, stride=2, padding=1) self.layer1 = self._make_layer(block, 128, layers[0], stride=1, cardinality=self.cardinality) self.layer2 = self._make_layer(block, 256, layers[1], stride=2, cardinality=self.cardinality) self.layer3 = self._make_layer(block, 512, layers[2], stride=2, cardinality=self.cardinality) self.layer4 = self._make_layer(block, 1024, layers[3], stride=2, cardinality=self.cardinality) self.flat = rm.Flatten() self.fc = rm.Dense(num_classes)
def layer_factory(channel=32, conv_layer_num=2): layers = [] for _ in range(conv_layer_num): layers.append(rm.Conv2d(channel=channel, padding=1, filter=3)) layers.append(rm.Relu()) layers.append(rm.MaxPool2d(filter=2, stride=2)) return rm.Sequential(layers)
def __init__(self, classes): super(Darknet19, self).__init__() ##### common layers for both pretrained layers and yolov2 ##### self.conv1 = rm.Conv2d(channel=32, filter=3, stride=1, padding=1) self.bn1 = rm.BatchNormalize(mode='feature') self.pool1 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv2 = rm.Conv2d(channel=64, filter=3, stride=1, padding=1) self.bn2 = rm.BatchNormalize(mode='feature') self.pool2 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv3 = rm.Conv2d(channel=128, filter=3, stride=1, padding=1) self.bn3 = rm.BatchNormalize(mode='feature') self.conv4 = rm.Conv2d(channel=64, filter=1, stride=1, padding=0) self.bn4 = rm.BatchNormalize(mode='feature') self.conv5 = rm.Conv2d(channel=128, filter=3, stride=1, padding=1) self.bn5 = rm.BatchNormalize(mode='feature') self.pool3 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv6 = rm.Conv2d(channel=256, filter=3, stride=1, padding=1) self.bn6 = rm.BatchNormalize(mode='feature') self.conv7 = rm.Conv2d(channel=128, filter=1, stride=1, padding=0) self.bn7 = rm.BatchNormalize(mode='feature') self.conv8 = rm.Conv2d(channel=256, filter=3, stride=1, padding=1) self.bn8 = rm.BatchNormalize(mode='feature') self.pool4 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv9 = rm.Conv2d(channel=512, filter=3, stride=1, padding=1) self.bn9 = rm.BatchNormalize(mode='feature') self.conv10 = rm.Conv2d(channel=256, filter=1, stride=1, padding=0) self.bn10 = rm.BatchNormalize(mode='feature') self.conv11 = rm.Conv2d(channel=512, filter=3, stride=1, padding=1) self.bn11 = rm.BatchNormalize(mode='feature') self.conv12 = rm.Conv2d(channel=256, filter=1, stride=1, padding=0) self.bn12 = rm.BatchNormalize(mode='feature') self.conv13 = rm.Conv2d(channel=512, filter=3, stride=1, padding=1) self.bn13 = rm.BatchNormalize(mode='feature') self.pool5 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv14 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) self.bn14 = rm.BatchNormalize(mode='feature') self.conv15 = rm.Conv2d(channel=512, filter=1, stride=1, padding=0) self.bn15 = rm.BatchNormalize(mode='feature') self.conv16 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) self.bn16 = rm.BatchNormalize(mode='feature') self.conv17 = rm.Conv2d(channel=512, filter=1, stride=1, padding=0) self.bn17 = rm.BatchNormalize(mode='feature') self.conv18 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) self.bn18 = rm.BatchNormalize(mode='feature') ###### pretraining layer self.conv23 = rm.Conv2d(channel=classes, filter=1, stride=1, padding=0)
def __init__(self): super(Cifar10, self).__init__() self._l1 = rm.Conv2d(channel=32) self._l2 = rm.Conv2d(channel=32) self._l3 = rm.Conv2d(channel=64) self._l4 = rm.Conv2d(channel=64) self._l5 = rm.Dense(512) self._l6 = rm.Dense(10) self._sd = rm.SpatialDropout(dropout_ratio=0.25) self._pool = rm.MaxPool2d(filter=2, stride=2)
def __init__(self, num_class): self.base1 = rm.Sequential([rm.Conv2d(64, filter=7, padding=3, stride=2), rm.Relu(), rm.MaxPool2d(filter=3, stride=2, padding=1), rm.BatchNormalize(mode='feature'), rm.Conv2d(64, filter=1, stride=1), rm.Relu(), rm.Conv2d(192, filter=3, padding=1, stride=1), rm.Relu(), rm.BatchNormalize(mode='feature'), rm.MaxPool2d(filter=3, stride=2, padding=1), InceptionV1Block(), InceptionV1Block([128, 128, 192, 32, 96, 64]), rm.MaxPool2d(filter=3, stride=2), InceptionV1Block([192, 96, 208, 16, 48, 64]), ]) self.aux1 = rm.Sequential([rm.AveragePool2d(filter=5, stride=3), rm.Flatten(), rm.Dense(1024), rm.Dense(num_class)]) self.base2 = rm.Sequential([InceptionV1Block([160, 112, 224, 24, 64, 64]), InceptionV1Block([128, 128, 256, 24, 64, 64]), InceptionV1Block([112, 144, 288, 32, 64, 64])]) self.aux2 = rm.Sequential([rm.AveragePool2d(filter=5, stride=3), rm.Flatten(), rm.Dense(1024), rm.Dense(num_class)]) self.base3 = rm.Sequential([InceptionV1Block([256, 160, 320, 32, 128, 128]), InceptionV1Block([256, 160, 320, 32, 128, 128]), InceptionV1Block([192, 384, 320, 48, 128, 128]), rm.AveragePool2d(filter=7, stride=1), rm.Flatten()]) self.aux3 = rm.Dense(num_class)
def __init__(self): self.block1 = rm.Sequential( [DarknetConv2dBN(32, prev_ch=3), rm.MaxPool2d(filter=2, stride=2)]) self.block2 = rm.Sequential([ DarknetConv2dBN(64, prev_ch=32), rm.MaxPool2d(filter=2, stride=2) ]) self.block3 = rm.Sequential([ DarknetConv2dBN(128, prev_ch=64), DarknetConv2dBN(64, filter=1, prev_ch=128), DarknetConv2dBN(128, prev_ch=64), rm.MaxPool2d(filter=2, stride=2) ]) self.block4 = rm.Sequential([ DarknetConv2dBN(256, prev_ch=128), DarknetConv2dBN(128, filter=1, prev_ch=256), DarknetConv2dBN(256, prev_ch=128), rm.MaxPool2d(filter=2, stride=2) ]) self.block5 = rm.Sequential([ DarknetConv2dBN(512, prev_ch=256), DarknetConv2dBN(256, filter=1, prev_ch=512), DarknetConv2dBN(512, prev_ch=256), DarknetConv2dBN(256, filter=1, prev_ch=512), DarknetConv2dBN(512, prev_ch=256), ]) self.block6 = rm.Sequential([ # For concatenation. rm.MaxPool2d(filter=2, stride=2), DarknetConv2dBN(1024, prev_ch=512), DarknetConv2dBN(512, filter=1, prev_ch=1024), DarknetConv2dBN(1024, prev_ch=512), DarknetConv2dBN(512, filter=1, prev_ch=1024), DarknetConv2dBN(1024, prev_ch=512), ])
def test_gpu_node_max_pooling(a): with use_cuda(): layer = rm.MaxPool2d() g1 = Variable(a) g3 = rm.sum(layer(g1)) g = g3.grad() g_g3 = g.get(g1) g3.to_cpu() c3 = rm.sum(layer(g1)) c3.grad() c_g3 = g.get(g1) close(g3, c3) close(c_g3, g_g3)
def test_max_pool2d(tmpdir): model = rm.Sequential([ rm.MaxPool2d(filter=2, stride=2), ]) input = renom.Variable(np.random.random((10, 10, 10, 10))) m = _run_onnx(tmpdir, model, input) # check input id_input, = m.graph.node[0].input assert 'input' == id_input assert get_shape(m.graph.input[0]) == input.shape # check output assert get_shape(m.graph.output[0]) == (10, 10, 5, 5) # check attrs attrs = dict((a.name, a) for a in m.graph.node[0].attribute) assert attrs['pads'].ints == [0, 0] assert attrs['kernel_shape'].ints == [2, 2] assert attrs['strides'].ints == [2, 2]
def __init__(self, num_class=1000, load_pretrained_weight=False): super(Darknet, self).__init__([ # 1st Block rm.Conv2d(channel=64, filter=7, stride=2, padding=3, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.MaxPool2d(stride=2, filter=2), # 2nd Block rm.Conv2d(channel=192, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.MaxPool2d(stride=2, filter=2), # 3rd Block rm.Conv2d(channel=128, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.MaxPool2d(stride=2, filter=2), # 4th Block rm.Conv2d(channel=256, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.MaxPool2d(stride=2, filter=2), # 5th Block rm.Conv2d(channel=512, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, padding=1, ignore_bias=True), rm.BatchNormalize(mode='feature'), rm.LeakyRelu(slope=0.1), # layers for ImageNet rm.Conv2d(channel=num_class, filter=1), rm.LeakyRelu(slope=0.1), rm.AveragePool2d(filter=7), rm.Softmax() ]) if load_pretrained_weight: if isinstance(load_pretrained_weight, bool): load_pretrained_weight = self.__class__.__name__ + '.h5' if not os.path.exists(load_pretrained_weight): download(self.WEIGHT_URL, load_pretrained_weight) self.load(load_pretrained_weight)
def __init__(self, classes, bbox): super(YOLOv2, self).__init__() self.bbox = bbox self.classes = classes self.anchors = [[5.375, 5.03125], [5.40625, 4.6875], [2.96875, 2.53125], [2.59375, 2.78125], [1.9375, 3.25]] self.thresh = 0.6 ##### common layers for both pretrained layers and yolov2 ##### self.conv1 = rm.Conv2d(channel=32, filter=3, stride=1, padding=1) self.bn1 = rm.BatchNormalize(mode='feature') self.pool1 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv2 = rm.Conv2d(channel=64, filter=3, stride=1, padding=1) self.bn2 = rm.BatchNormalize(mode='feature') self.pool2 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv3 = rm.Conv2d(channel=128, filter=3, stride=1, padding=1) self.bn3 = rm.BatchNormalize(mode='feature') self.conv4 = rm.Conv2d(channel=64, filter=1, stride=1, padding=0) self.bn4 = rm.BatchNormalize(mode='feature') self.conv5 = rm.Conv2d(channel=128, filter=3, stride=1, padding=1) self.bn5 = rm.BatchNormalize(mode='feature') self.pool3 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv6 = rm.Conv2d(channel=256, filter=3, stride=1, padding=1) self.bn6 = rm.BatchNormalize(mode='feature') self.conv7 = rm.Conv2d(channel=128, filter=1, stride=1, padding=0) self.bn7 = rm.BatchNormalize(mode='feature') self.conv8 = rm.Conv2d(channel=256, filter=3, stride=1, padding=1) self.bn8 = rm.BatchNormalize(mode='feature') self.pool4 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv9 = rm.Conv2d(channel=512, filter=3, stride=1, padding=1) self.bn9 = rm.BatchNormalize(mode='feature') self.conv10 = rm.Conv2d(channel=256, filter=1, stride=1, padding=0) self.bn10 = rm.BatchNormalize(mode='feature') self.conv11 = rm.Conv2d(channel=512, filter=3, stride=1, padding=1) self.bn11 = rm.BatchNormalize(mode='feature') self.conv12 = rm.Conv2d(channel=256, filter=1, stride=1, padding=0) self.bn12 = rm.BatchNormalize(mode='feature') self.conv13 = rm.Conv2d(channel=512, filter=3, stride=1, padding=1) self.bn13 = rm.BatchNormalize(mode='feature') self.pool5 = rm.MaxPool2d(filter=2, stride=2, padding=0) self.conv14 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) self.bn14 = rm.BatchNormalize(mode='feature') self.conv15 = rm.Conv2d(channel=512, filter=1, stride=1, padding=0) self.bn15 = rm.BatchNormalize(mode='feature') self.conv16 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) self.bn16 = rm.BatchNormalize(mode='feature') self.conv17 = rm.Conv2d(channel=512, filter=1, stride=1, padding=0) self.bn17 = rm.BatchNormalize(mode='feature') self.conv18 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) self.bn18 = rm.BatchNormalize(mode='feature') ###### pretraining layer self.conv23 = rm.Conv2d(channel=classes, filter=1, stride=1, padding=0) ###### detection layer self.conv19 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) self.bn19 = rm.BatchNormalize(mode='feature') self.conv20 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) self.bn20 = rm.BatchNormalize(mode='feature') self.conv21 = rm.Conv2d(channel=1024, filter=3, stride=1, padding=1) ##input=3072 self.bn21 = rm.BatchNormalize(mode='feature') self.conv22 = rm.Conv2d(channel=bbox * (5 + classes), filter=1, stride=1, padding=0)
def __init__(self, num_class, vgg): self.num_class = num_class block3 = vgg._model.block3 self.conv3_1 = block3._layers[0] self.conv3_2 = block3._layers[2] self.conv3_3 = block3._layers[4] self.pool3 = rm.MaxPool2d(filter=2, stride=2, padding=1) self.norm = rm.L2Norm(20) block4 = vgg._model.block4 self.conv4_1 = block4._layers[0] self.conv4_2 = block4._layers[2] self.conv4_3 = block4._layers[4] self.pool4 = rm.MaxPool2d(filter=2, stride=2) block5 = vgg._model.block5 self.conv5_1 = block5._layers[0] self.conv5_2 = block5._layers[2] self.conv5_3 = block5._layers[4] self.pool5 = rm.MaxPool2d(filter=3, stride=1, padding=1) # ================================================= # THOSE ARE USED AFTER OUTPUS ARE NORMALIZED self.fc6 = rm.Conv2d(channel=1024, filter=3, padding=6, dilation=6) # relu self.fc7 = rm.Conv2d(channel=1024, filter=1, padding=0) self.conv8_1 = rm.Conv2d(channel=256, filter=1) self.conv8_2 = rm.Conv2d(channel=512, stride=2, filter=3, padding=1) self.conv9_1 = rm.Conv2d(channel=128, filter=1) self.conv9_2 = rm.Conv2d(channel=256, stride=2, filter=3, padding=1) self.conv10_1 = rm.Conv2d(channel=128, filter=1, padding=0) self.conv10_2 = rm.Conv2d(channel=256, padding=0, stride=1, filter=3) self.conv11_1 = rm.Conv2d(channel=128, filter=1, padding=0) self.conv11_2 = rm.Conv2d(channel=256, padding=0, stride=1, filter=3) num_priors = 4 self.conv4_3_mbox_loc = rm.Conv2d(num_priors * 4, padding=1, filter=3) self.conv4_3_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) # ================================================= # ================================================= num_priors = 6 self.fc7_mbox_loc = rm.Conv2d(num_priors * 4, padding=1) self.fc7_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) # ================================================= # ================================================= self.conv8_2_mbox_loc = rm.Conv2d(num_priors * 4, padding=1, filter=3) self.conv8_2_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) # ================================================= # ================================================= self.conv9_2_mbox_loc = rm.Conv2d(num_priors * 4, padding=1) self.conv9_2_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) # ================================================= # ================================================= num_priors = 4 self.conv10_2_mbox_loc = rm.Conv2d(num_priors * 4, padding=1) self.conv10_2_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) # ================================================= # ================================================= num_priors = 4 self.conv11_2_mbox_loc = rm.Conv2d(num_priors * 4, padding=1) self.conv11_2_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3)
def __init__(self, last_unit_size, load_weight_path=None): # TODO: Passing last_unit_size is not good. assert load_weight_path is None or isinstance(load_weight_path, str) super(Darknet, self).__init__([ # 1st Block rm.Conv2d(channel=64, filter=7, stride=2, padding=3), rm.LeakyRelu(slope=0.1), rm.MaxPool2d(stride=2, filter=2), # 2nd Block rm.Conv2d(channel=192, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.MaxPool2d(stride=2, filter=2), # 3rd Block rm.Conv2d(channel=128, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.MaxPool2d(stride=2, filter=2), # 4th Block rm.Conv2d(channel=256, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=256, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.MaxPool2d(stride=2, filter=2), # 5th Block rm.Conv2d(channel=512, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=512, filter=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, stride=2, padding=1), rm.LeakyRelu(slope=0.1), # 6th Block rm.Conv2d(channel=1024, filter=3, padding=1), rm.LeakyRelu(slope=0.1), rm.Conv2d(channel=1024, filter=3, padding=1), rm.LeakyRelu(slope=0.1), # 7th Block rm.Flatten(), rm.Dense(1024), rm.LeakyRelu(slope=0.1), rm.Dense(4096), rm.LeakyRelu(slope=0.1), rm.Dropout(0.5), # 8th Block rm.Dense(last_unit_size), ]) if load_weight_path is not None: # Call download method. path, ext = os.path.splitext(load_weight_path) if ext: self.load(load_weight_path) else: self.load(path + '.h5')
def __init__(self, num_class, vgg): self.num_class = num_class block3 = vgg._model.block3 self.conv3_1 = block3._layers[0] self.conv3_2 = block3._layers[2] self.conv3_3 = block3._layers[4] self.pool3 = rm.MaxPool2d(filter=2, stride=2, padding=1) block4 = vgg._model.block4 self.conv4_1 = block4._layers[0] self.conv4_2 = block4._layers[2] self.conv4_3 = block4._layers[4] self.pool4 = rm.MaxPool2d(filter=2, stride=2) block5 = vgg._model.block5 self.conv5_1 = block5._layers[0] self.conv5_2 = block5._layers[2] self.conv5_3 = block5._layers[4] self.pool5 = rm.MaxPool2d(filter=3, stride=1, padding=1) #================================================= # THOSE ARE USED AFTER OUTPUS ARE NORMALIZED self.fc6 = rm.Conv2d(channel=1024, filter=3, padding=6, dilation=6) # relu self.fc7 = rm.Conv2d(channel=1024, filter=1, padding=0) self.conv8_1 = rm.Conv2d(channel=256, filter=1) self.conv8_2 = rm.Conv2d(channel=512, stride=2, filter=3, padding=1) self.conv9_1 = rm.Conv2d(channel=128, filter=1) self.conv9_2 = rm.Conv2d(channel=256, stride=2, filter=3, padding=1) self.conv10_1 = rm.Conv2d(channel=128, filter=1, padding=0) self.norm = rm.L2Norm(20) self.conv10_2 = rm.Conv2d(channel=256, padding=1, stride=2, filter=3) num_priors = 3 self.conv4_3_mbox_loc = rm.Conv2d(num_priors * 4, padding=1, filter=3) self.conv4_3_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) # define the PriorBox class later self.conv4_3_priorbox = PriorBox((300, 300), 30.0, aspect_ratios=[2], variances=[0.1, 0.1, 0.2, 0.2]) #================================================= #================================================= num_priors = 6 self.fc7_mbox_loc = rm.Conv2d(num_priors * 4, padding=1) self.fc7_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) self.fc7_priorbox = PriorBox((300, 300), 114.0, max_size=168.0, aspect_ratios=[2, 3], variances=[0.1, 0.1, 0.2, 0.2]) #================================================= #================================================= self.conv8_2_mbox_loc = rm.Conv2d(num_priors * 4, padding=1, filter=3) self.conv8_2_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) self.conv8_2_priorbox = PriorBox((300, 300), 114.0, max_size=168.0, aspect_ratios=[2, 3], variances=[0.1, 0.1, 0.2, 0.2]) #================================================= #================================================= self.conv9_2_mbox_loc = rm.Conv2d(num_priors * 4, padding=1) self.conv9_2_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) self.conv9_2_priorbox = PriorBox((300, 300), 168.0, max_size=222.0, aspect_ratios=[2, 3], variances=[0.1, 0.1, 0.2, 0.2]) #================================================= #================================================= self.conv10_2_mbox_loc = rm.Conv2d(num_priors * 4, padding=1) self.conv10_2_mbox_conf = rm.Conv2d(num_priors * num_class, padding=1, filter=3) self.conv10_2_priorbox = PriorBox((300, 300), 222.0, max_size=276.0, aspect_ratios=[2, 3], variances=[0.1, 0.1, 0.2, 0.2]) #================================================= self.pool11_mbox_loc = rm.Dense(num_priors * 4) self.pool11_mbox_conf = rm.Dense(num_priors * num_class) self.pool11_priorbox = PriorBox((300, 300), 276.0, max_size=330.0, aspect_ratios=[2, 3], variances=[0.1, 0.1, 0.2, 0.2])