def create_block_list(self):
        self.clear_list()

        backbone = self.factory.get_base_model(BackboneName.Vgg19,
                                               self.data_channel)
        base_out_channels = backbone.get_outchannel_list()
        self.add_block_list(BlockType.BaseNet, backbone, base_out_channels[-1])

        # avgpool = nn.AdaptiveAvgPool2d((7, 7))

        layer1 = FcLayer(base_out_channels[-1], 4096)
        self.add_block_list(layer1.get_name(), layer1, 4096)

        layer2 = ActivationLayer(self.activation_name, inplace=False)
        self.add_block_list(layer2.get_name(), layer2, 4096)

        layer3 = nn.Dropout()
        self.add_block_list(LayerType.Dropout, layer3, 4096)

        layer4 = nn.Linear(4096, 4096)
        self.add_block_list(LayerType.FcLinear, layer4, 4096)

        layer5 = ActivationLayer(self.activation_name, inplace=False)
        self.add_block_list(layer5.get_name(), layer5, 4096)

        layer6 = nn.Dropout()
        self.add_block_list(LayerType.Dropout, layer6, 4096)

        layer7 = nn.Linear(4096, self.class_number)
        self.add_block_list(LayerType.FcLinear, layer7, self.class_number)

        self.create_loss()
Beispiel #2
0
    def create_block_list(self):
        self.clear_list()

        backbone = self.factory.get_base_model(BackboneName.GhostNet,
                                               self.data_channel)
        base_out_channels = backbone.get_outchannel_list()
        self.add_block_list(BlockType.BaseNet, backbone, base_out_channels[-1])

        avgpool = nn.AdaptiveAvgPool2d((1, 1))
        self.add_block_list(LayerType.GlobalAvgPool, avgpool,
                            base_out_channels[-1])

        output_channel = 1280
        layer1 = FcLayer(base_out_channels[-1], output_channel)
        self.add_block_list(layer1.get_name(), layer1, output_channel)

        layer2 = NormalizeLayer(bn_name=NormalizationType.BatchNormalize1d,
                                out_channel=output_channel)
        self.add_block_list(layer2.get_name(), layer2, output_channel)

        layer3 = ActivationLayer(self.activation_name, inplace=False)
        self.add_block_list(layer3.get_name(), layer3, output_channel)

        layer4 = nn.Dropout(0.2)
        self.add_block_list(LayerType.Dropout, layer4, output_channel)

        layer5 = nn.Linear(output_channel, self.class_number)
        self.add_block_list(LayerType.FcLinear, layer5, self.class_number)

        self.create_loss()
Beispiel #3
0
    def create_block_list(self):
        self.clear_list()

        backbone = PointNet(data_channel=self.data_channel,
                            feature_transform=self.feature_transform,
                            bn_name=self.bn_name,
                            activation_name=self.activation_name)
        base_out_channels = backbone.get_outchannel_list()
        self.add_block_list(BlockType.BaseNet, backbone, base_out_channels[-1])

        input_channel = self.block_out_channels[-1]
        fc1 = FcBNActivationBlock(input_channel,
                                  512,
                                  bnName=self.bn_name,
                                  activationName=self.activation_name)
        self.add_block_list(fc1.get_name(), fc1, 512)

        input_channel = 512
        fc2 = nn.Linear(input_channel, 256)
        self.add_block_list(LayerType.FcLinear, fc2, 256)

        input_channel = 256
        dropout = nn.Dropout(p=0.3)
        self.add_block_list(LayerType.Dropout, dropout, input_channel)

        normalize = NormalizeLayer(self.bn_name, input_channel)
        self.add_block_list(normalize.get_name(), normalize, input_channel)

        activate = ActivationLayer(self.activation_name, inplace=False)
        self.add_block_list(activate.get_name(), activate, input_channel)

        fc3 = nn.Linear(input_channel, self.class_number)
        self.add_block_list(LayerType.FcLinear, fc3, self.class_number)

        self.create_loss()
    def create_block_list(self):
        self.clear_list()

        if (self.scale < 0.99) or (self.scale > 1.001):
            up = Upsample(scale_factor=self.scale, mode='nearest')
            self.add_block_list(up.get_name(), up, self.data_channel)

        stage1 = ConvBNActivationBlock(in_channels=self.data_channel,
                                       out_channels=self.out_channels[0],
                                       kernel_size=3,
                                       stride=2,
                                       padding=1,
                                       bias=False,
                                       bnName=self.bn_name,
                                       activationName=self.activation_name)
        self.add_block_list(stage1.get_name(), stage1, self.out_channels[0])

        for index, number in enumerate(self.repeats):
            self.make_layers(number, self.out_channels[index],
                             self.out_channels[index + 1],
                             self.kernel_sizes[index], self.strides[index],
                             self.expands[index])
            activate = ActivationLayer(activation_name=self.activation_name)
            self.add_block_list(activate.get_name(), activate,
                                self.block_out_channels[-1])

        stage9 = ConvBNActivationBlock(in_channels=self.out_channels[7],
                                       out_channels=self.out_channels[8],
                                       kernel_size=1,
                                       stride=1,
                                       padding=0,
                                       bias=False,
                                       bnName=self.bn_name,
                                       activationName=self.activation_name)
        self.add_block_list(stage9.get_name(), stage9, self.out_channels[8])
    def create_block_list(self):
        self.clear_list()

        layer1 = ConvBNActivationBlock(in_channels=self.data_channel,
                                       out_channels=self.num_init_features,
                                       kernel_size=7,
                                       stride=2,
                                       padding=3,
                                       bnName=self.bnName,
                                       activationName=self.activationName)
        self.add_block_list(layer1.get_name(), layer1, self.num_init_features)

        layer2 = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
        self.add_block_list(LayerType.MyMaxPool2d, layer2,
                            self.num_init_features)

        self.in_channels = self.num_init_features
        for index, num_block in enumerate(self.num_blocks):
            self.make_densenet_layer(num_block, self.dilations[index],
                                     self.bn_size, self.growth_rate,
                                     self.drop_rate, self.bnName,
                                     self.activationName)
            self.in_channels = self.block_out_channels[-1]
            if index != len(self.num_blocks) - 1:
                trans = TransitionBlock(in_channel=self.in_channels,
                                        output_channel=self.in_channels // 2,
                                        stride=1,
                                        bnName=self.bnName,
                                        activationName=self.activationName)
                self.add_block_list(trans.get_name(), trans,
                                    self.in_channels // 2)
                avg_pool = nn.AvgPool2d(kernel_size=2, stride=2)
                self.add_block_list(LayerType.GlobalAvgPool, avg_pool,
                                    self.block_out_channels[-1])
                self.in_channels = self.block_out_channels[-1]
        layer3 = NormalizeLayer(bn_name=self.bnName,
                                out_channel=self.in_channels)
        self.add_block_list(layer3.get_name(), layer3, self.in_channels)

        layer4 = ActivationLayer(self.activationName, False)
        self.add_block_list(layer4.get_name(), layer4, self.in_channels)
    def create_block_list(self):
        self.block_out_channels = []
        self.index = 0

        stem = ConvBNActivationBlock(in_channels=self.data_channel,
                                     out_channels=self.first_output,
                                     kernel_size=3,
                                     padding=1,
                                     bias=False,
                                     bnName=self.bn_name,
                                     activationName=ActivationType.Linear)
        self.add_block_list(stem.get_name(), stem, self.first_output)

        for i in range(self.reduction_num):
            self.make_normal(NormalCell, self.repeat_cell_num, self.filters)
            self.filters *= 2
            self.make_reduction(ReductionCell, self.filters)

        self.make_normal(NormalCell, self.repeat_cell_num, self.filters)

        relu = ActivationLayer(activation_name=self.activation_name,
                               inplace=False)
        self.add_block_list(relu.get_name(), relu, self.filters * 6)