Exemple #1
0
    def build_from_config(config):
        enc_first_conv = set_layer_from_config(config['enc_first_conv'])
        enc_input_skip_conn = set_layer_from_config(
            config['enc_input_skip_conn'])
        enc_final_conv_blocks = []
        for block_config in config['enc_final_conv_blocks']:
            enc_final_conv_blocks.append(
                MobileInvertedResidualBlock.build_from_config(block_config))

        blocks = []
        for block_config in config['blocks']:
            blocks.append(
                MobileInvertedResidualBlock.build_from_config(block_config))

        dec_first_conv = set_layer_from_config(config['dec_first_conv'])
        dec_input_skip_conn = set_layer_from_config(
            config['dec_input_skip_conn'])
        dec_final_conv_blocks = []
        for block_config in config['dec_final_conv_blocks']:
            enc_final_conv_blocks.append(set_layer_from_config(block_config))

        net = MobileNetX4(enc_first_conv, enc_input_skip_conn,
                          enc_final_conv_blocks, blocks, dec_first_conv,
                          dec_input_skip_conn, dec_final_conv_blocks)
        if 'bn' in config:
            net.set_bn_param(**config['bn'])
        else:
            net.set_bn_param(momentum=0.1, eps=1e-3)

        return net
Exemple #2
0
    def build_from_config(config):
        first_conv = set_layer_from_config(config['first_conv'])
        final_expand_layer = set_layer_from_config(config['final_expand_layer'])
        feature_mix_layer = set_layer_from_config(config['feature_mix_layer'])
        classifier = set_layer_from_config(config['classifier'])

        blocks = []
        for block_config in config['blocks']:
            blocks.append(MobileInvertedResidualBlock.build_from_config(block_config))

        net = MobileNetV3(first_conv, blocks, final_expand_layer, feature_mix_layer, classifier)
        if 'bn' in config:
            net.set_bn_param(**config['bn'])
        else:
            net.set_bn_param(momentum=0.1, eps=1e-3)

        return net
Exemple #3
0
    def build_from_config(config, drop_connect_rate=0.0, depth=None):
        first_conv = set_layer_from_config(config['first_conv'])
        final_expand_layer = set_layer_from_config(config['final_expand_layer'])
        feature_mix_layer = set_layer_from_config(config['feature_mix_layer'])
        classifier = set_layer_from_config(config['classifier'])

        blocks = []
        for block_idx, block_config in enumerate(config['blocks']):
            block_config['drop_connect_rate'] = drop_connect_rate * block_idx / len(config['blocks'])
            blocks.append(MobileInvertedResidualBlock.build_from_config(block_config))

        net = MobileNetV3(first_conv, blocks, final_expand_layer, feature_mix_layer, classifier, depth)
        if 'bn' in config:
            net.set_bn_param(**config['bn'])
        else:
            net.set_bn_param(momentum=0.1, eps=1e-3)

        return net
Exemple #4
0
 def build_from_config(config):
     mobile_inverted_conv = set_layer_from_config(
         config['mobile_inverted_conv'])
     shortcut = set_layer_from_config(config['shortcut'])
     return MobileInvertedResidualBlock(mobile_inverted_conv, shortcut)