Пример #1
0
    def __init__(self,
                 hidden_units=None,
                 reduce_factor=None,
                 dnn_dropout=None,
                 use_bn=None,
                 dnn_layers=None,
                 activation=None,
                 space=None,
                 name=None,
                 **hyperparams):
        if hidden_units is None:
            hidden_units = Choice([100, 200, 300, 500, 800, 1000])
        hyperparams['hidden_units'] = hidden_units

        if reduce_factor is None:
            reduce_factor = Choice([1, 0.8, 0.5])
        hyperparams['reduce_factor'] = reduce_factor

        if dnn_dropout is None:
            dnn_dropout = Choice([0, 0.1, 0.3, 0.5])
        hyperparams['dnn_dropout'] = dnn_dropout

        if use_bn is None:
            use_bn = Bool()
        hyperparams['use_bn'] = use_bn

        if dnn_layers is None:
            dnn_layers = Choice([1, 2, 3])
        hyperparams['dnn_layers'] = dnn_layers

        if activation is None:
            activation = 'relu'
        hyperparams['activation'] = activation

        ModuleSpace.__init__(self, space, name, **hyperparams)
Пример #2
0
def cnn_search_space(input_shape, output_units, output_activation='softmax', block_num_choices=[2, 3, 4, 5, 6],
                     activation_choices=['relu'], filters_choices=[32, 64], kernel_size_choices=[(1, 1), (3, 3)]):
    space = HyperSpace()
    with space.as_default():
        hp_use_bn = Bool()
        hp_pooling = Choice(list(range(2)))
        hp_filters = Choice(filters_choices)
        hp_kernel_size = Choice(kernel_size_choices)
        hp_fc_units = Choice([1024, 2048, 4096])
        if len(activation_choices) == 1:
            hp_activation = activation_choices[0]
        else:
            hp_activation = Choice(activation_choices)
        hp_bn_act = Choice([seq for seq in itertools.permutations(range(2))])

        input = Input(shape=input_shape)
        blocks = Repeat(
            lambda step: conv_block(
                block_no=step,
                hp_pooling=hp_pooling,
                hp_filters=hp_filters,
                hp_kernel_size=hp_kernel_size,
                hp_use_bn=hp_use_bn,
                hp_activation=hp_activation,
                hp_bn_act=hp_bn_act),
            repeat_times=block_num_choices)(input)
        x = Flatten()(blocks)
        x = Dense(units=hp_fc_units, activation=hp_activation, name='fc1')(x)
        x = Dense(units=hp_fc_units, activation=hp_activation, name='fc2')(x)
        x = Dense(output_units, activation=output_activation, name='predictions')(x)
    return space
Пример #3
0
def mini_dt_space():
    space = HyperSpace()
    with space.as_default():
        p_nets = MultipleChoice(['dnn_nets', 'linear', 'fm_nets'],
                                num_chosen_most=2)
        dt_module = DTModuleSpace(nets=p_nets,
                                  auto_categorize=Bool(),
                                  cat_remain_numeric=Bool(),
                                  auto_discrete=Bool(),
                                  apply_gbm_features=Bool(),
                                  gbm_feature_type=Choice([
                                      DT_consts.GBM_FEATURE_TYPE_DENSE,
                                      DT_consts.GBM_FEATURE_TYPE_EMB
                                  ]),
                                  embeddings_output_dim=Choice([4, 10]),
                                  embedding_dropout=Choice([0, 0.5]),
                                  stacking_op=Choice([
                                      DT_consts.STACKING_OP_ADD,
                                      DT_consts.STACKING_OP_CONCAT
                                  ]),
                                  output_use_bias=Bool(),
                                  apply_class_weight=Bool(),
                                  earlystopping_patience=Choice([1, 3, 5]))
        dnn = DnnModule(hidden_units=Choice([100, 200]),
                        reduce_factor=Choice([1, 0.8]),
                        dnn_dropout=Choice([0, 0.3]),
                        use_bn=Bool(),
                        dnn_layers=2,
                        activation='relu')(dt_module)
        fit = DTFit(batch_size=Choice([128, 256]))(dt_module)

    return space
Пример #4
0
def get_space():
    space = HyperSpace()
    with space.as_default():
        p1 = Int(1, 100)
        p2 = Choice(['a', 'b'])
        p3 = Bool()
        p4 = Real(0.0, 1.0)
        id1 = Identity(p1=p1)
        id2 = Identity(p2=p2)(id1)
        id3 = Identity(p3=p3)(id2)
        id4 = Identity(p4=p4)(id3)
    return space
Пример #5
0
def default_dt_space():
    space = HyperSpace()
    with space.as_default():
        p_nets = MultipleChoice([
            'dnn_nets', 'linear', 'cin_nets', 'fm_nets', 'afm_nets',
            'pnn_nets', 'cross_nets', 'cross_dnn_nets', 'dcn_nets',
            'autoint_nets', 'fgcnn_dnn_nets', 'fibi_dnn_nets'
        ],
                                num_chosen_most=3)
        dt_module = DTModuleSpace(
            nets=p_nets,
            auto_categorize=Bool(),
            cat_remain_numeric=Bool(),
            auto_discrete=Bool(),
            apply_gbm_features=Bool(),
            gbm_feature_type=Choice([
                DT_consts.GBM_FEATURE_TYPE_DENSE,
                DT_consts.GBM_FEATURE_TYPE_EMB
            ]),
            embeddings_output_dim=Choice([4, 10, 20]),
            embedding_dropout=Choice([0, 0.1, 0.2, 0.3, 0.4, 0.5]),
            stacking_op=Choice(
                [DT_consts.STACKING_OP_ADD, DT_consts.STACKING_OP_CONCAT]),
            output_use_bias=Bool(),
            apply_class_weight=Bool(),
            earlystopping_patience=Choice([1, 3, 5]))
        dnn = DnnModule()(dt_module)
        fit = DTFit(batch_size=Choice([128, 256]))(dt_module)

    return space
Пример #6
0
def tiny_dt_space(**hyperparams):
    space = HyperSpace()
    with space.as_default():
        dt_module = DTModuleSpace(nets=['dnn_nets'],
                                  auto_categorize=Bool(),
                                  cat_remain_numeric=Bool(),
                                  auto_discrete=False,
                                  apply_gbm_features=False,
                                  stacking_op=Choice([
                                      DT_consts.STACKING_OP_ADD,
                                      DT_consts.STACKING_OP_CONCAT
                                  ]),
                                  output_use_bias=Bool(),
                                  apply_class_weight=Bool(),
                                  earlystopping_patience=Choice([1, 3, 5]))
        dnn = DnnModule(hidden_units=Choice([10, 20]),
                        reduce_factor=1,
                        dnn_dropout=Choice([0, 0.3]),
                        use_bn=False,
                        dnn_layers=2,
                        activation='relu')(dt_module)
        fit = DTFit(**hyperparams)(dt_module)

    return space
Пример #7
0
 def get_space():
     space = HyperSpace()
     with space.as_default():
         id1 = Identity(p1=Int(0, 10), p2=Choice(['a', 'b']))
         id2 = Identity(p3=Real(0., 1.), p4=Bool())(id1)
     return space