Ejemplo n.º 1
0
def create_problem(load_data):
    Problem = NaProblem(seed=2019)

    Problem.load_data(load_data)

    #Problem.preprocessing(minmaxstdscaler)

    Problem.search_space(create_search_space, num_layers=10)

    Problem.hyperparameters(
        verbose=0,
        batch_size=100,
        learning_rate=0.001,  #lr search: 0.01, lr post: 0.001
        optimizer='adam',
        num_epochs=50,
        callbacks=dict(EarlyStopping=dict(
            monitor='val_r2', mode='max', verbose=0, patience=5)))

    Problem.loss('mse')

    Problem.metrics(['r2'])

    Problem.objective('val_r2__last')

    Problem.post_training(num_epochs=1000,
                          metrics=['r2'],
                          callbacks=dict(ModelCheckpoint={
                              'monitor': 'val_r2',
                              'mode': 'max',
                              'save_best_only': True,
                              'verbose': 1
                          },
                                         EarlyStopping={
                                             'monitor': 'val_r2',
                                             'mode': 'max',
                                             'verbose': 1,
                                             'patience': 50
                                         },
                                         TensorBoard=dict(log_dir='{}'.format(
                                             time.time()), )))

    if __name__ == '__main__':
        print(Problem)
        from pprint import pprint
        pprint(Problem.space)
Ejemplo n.º 2
0
# Problem.preprocessing(minmaxstdscaler)

Problem.search_space(create_structure, num_cells=3)

Problem.hyperparameters(
    batch_size=64,
    learning_rate=0.001,
    optimizer='adam',
    num_epochs=1,
)

Problem.loss('mse')

Problem.metrics(['r2'])

Problem.objective('val_r2__last')

Problem.post_training(num_epochs=1000,
                      metrics=['r2'],
                      model_checkpoint={
                          'monitor': 'val_r2',
                          'mode': 'max',
                          'save_best_only': True,
                          'verbose': 1
                      },
                      early_stopping={
                          'monitor': 'val_r2',
                          'mode': 'max',
                          'verbose': 1,
                          'patience': 20
                      })
Ejemplo n.º 3
0
from deephyper.benchmark import NaProblem
from deephyper.benchmark.nas.linearReg.load_data import load_data
from deephyper.benchmark.nas.linearRegMultiInputsGen.load_data import load_data
from deephyper.search.nas.model.baseline.simple import create_search_space
from deephyper.search.nas.model.preprocessing import minmaxstdscaler

Problem = NaProblem()

Problem.load_data(load_data)

Problem.preprocessing(minmaxstdscaler)

Problem.search_space(create_search_space)

Problem.hyperparameters(
    batch_size=100,
    learning_rate=0.1,
    optimizer='adam',
    num_epochs=10,
)

Problem.loss('mse')

Problem.metrics(['r2'])

Problem.objective('val_r2')

# Just to print your problem, to test its definition and imports in the current python environment.
if __name__ == '__main__':
    print(Problem)
Ejemplo n.º 4
0
Problem.load_data(load_data)

# Problem.preprocessing(minmaxstdscaler)

Problem.search_space(create_search_space, num_layers=10)

Problem.hyperparameters(batch_size=100,
                        learning_rate=0.1,
                        optimizer="adam",
                        num_epochs=20)

Problem.loss(
    loss={
        "output_0": "mse",
        "output_1": "mse"
    },
    weights={
        "output_0": 0.0,
        "output_1": 1.0
    },
)

Problem.metrics({"output_0": ["r2", "mse"], "output_1": "mse"})

Problem.objective("val_output_0_r2")

# Just to print your problem, to test its definition and imports in the current python environment.
if __name__ == "__main__":
    print(Problem)
Ejemplo n.º 5
0
Problem.hyperparameters(
    batch_size=8,
    learning_rate=0.01,
    optimizer='adam',
    num_epochs=200,
    callbacks=dict(EarlyStopping=dict(
        monitor='r2',  # or 'val_acc' ?
        mode='max',
        verbose=0,
        patience=5)))

Problem.loss('mse')  # or 'categorical_crossentropy' ?

Problem.metrics(['r2'])  # or 'acc' ?

Problem.objective('r2__max')  # or 'val_acc__last' ?

Problem.post_training(
    repeat=1,
    num_epochs=1000,
    metrics=["mse", "r2"],
    callbacks=dict()
    # callbacks=dict(
    #     ModelCheckpoint={
    #         'monitor': 'val_r2',
    #         'mode': 'max',
    #         'save_best_only': True,
    #         'verbose': 1
    #     },
    #     EarlyStopping={
    #         'monitor': 'val_r2',
Ejemplo n.º 6
0
from deephyper.benchmark import NaProblem
from deephyper.benchmark.nas.linearRegMultiVar.load_data import load_data
from deephyper.search.nas.model.baseline.simple_deep import create_search_space
from deephyper.search.nas.model.preprocessing import minmaxstdscaler

Problem = NaProblem(seed=2019)

Problem.load_data(load_data)

# Problem.preprocessing(minmaxstdscaler)

Problem.search_space(create_search_space)

Problem.hyperparameters(batch_size=100,
                        learning_rate=0.1,
                        optimizer="adam",
                        num_epochs=1)

Problem.loss("mse")

Problem.metrics(["r2"])

Problem.objective("val_r2")

# Just to print your problem, to test its definition and imports in the current python environment.
if __name__ == "__main__":
    print(Problem)
Ejemplo n.º 7
0
from deephyper.benchmark import NaProblem
from deephyper.benchmark.nas.mnist1D.load_data import load_data
from deephyper.search.nas.model.baseline.simple import create_search_space
from deephyper.search.nas.model.preprocessing import minmaxstdscaler

Problem = NaProblem()

Problem.load_data(load_data)

Problem.search_space(create_search_space)

Problem.hyperparameters(
    batch_size=100,
    learning_rate=0.1,
    optimizer='adam',
    num_epochs=10,
)

Problem.loss('categorical_crossentropy')

Problem.metrics(['acc'])

Problem.objective('val_acc')

# Just to print your problem, to test its definition and imports in the current python environment.
if __name__ == '__main__':
    print(Problem)
Ejemplo n.º 8
0
# Problem.preprocessing(minmaxstdscaler)

Problem.search_space(create_structure)

Problem.hyperparameters(
    batch_size=20,
    learning_rate=0.01,
    optimizer='adam',
    num_epochs=1,
)

Problem.loss('categorical_crossentropy')

Problem.metrics(['acc'])

Problem.objective('val_acc__last')

Problem.post_training(num_epochs=1000,
                      metrics=['acc'],
                      model_checkpoint={
                          'monitor': 'val_acc',
                          'mode': 'max',
                          'save_best_only': True,
                          'verbose': 1
                      },
                      early_stopping={
                          'monitor': 'val_acc',
                          'mode': 'max',
                          'verbose': 1,
                          'patience': 20
                      })
Ejemplo n.º 9
0
from search_space import create_search_space
from deephyper.search.nas.model.preprocessing import minmaxstdscaler

Problem = NaProblem(seed=2019)

Problem.load_data(load_data)

# Problem.preprocessing(minmaxstdscaler)

Problem.search_space(create_search_space, num_layers=5)

Problem.hyperparameters(
    batch_size=32,
    learning_rate=0.001,
    optimizer='adam',
    num_epochs=20,
    callbacks=dict(EarlyStopping=dict(
        monitor='r2',  # or 'val_acc' ?
        mode='max',
        verbose=0,
        patience=10)))

Problem.loss('mse')  # or 'categorical_crossentropy' ?

Problem.metrics(['r2'])  # or 'acc' ?

Problem.objective('val_r2__last')  # or 'val_acc__last' ?

# Just to print your problem, to test its definition and imports in the current python environment.
if __name__ == '__main__':
    print(Problem)
Ejemplo n.º 10
0
Problem.metrics(["binary_accuracy"])  # or 'acc' ?

# def myacc_with_pred(info):
#     from sklearn.metrics import accuracy_score
#     import numpy as np

#     y_pred = np.array(info["y_pred"])
#     y_pred = (y_pred >= 0.5).astype(np.int32)
#     y_true = np.array(info["y_true"], dtype=np.int32)

#     acc = (y_true.flatten() == y_pred.flatten()).astype(int).sum() / len(y_true.flatten())
#     # acc = accuracy_score(y_true, y_pred)

#     return acc

Problem.objective("binary_accuracy__max")  # or 'val_acc__last' ?

Problem.post_training(
    repeat=1,
    num_epochs=3000,
    metrics=["binary_accuracy"],
    callbacks=dict()
    # callbacks=dict(
    #     ModelCheckpoint={
    #         'monitor': 'val_r2',
    #         'mode': 'max',
    #         'save_best_only': True,
    #         'verbose': 1
    #     },
    #     EarlyStopping={
    #         'monitor': 'val_r2',
Ejemplo n.º 11
0
Problem.load_data(load_data)

Problem.preprocessing(minmaxstdscaler)

Problem.search_space(create_search_space)

Problem.hyperparameters(
    batch_size=8,
    learning_rate=0.01,
    optimizer="adam",
    num_epochs=200,
    verbose=0,
    callbacks=dict(EarlyStopping=dict(
        monitor="r2",
        mode="max",
        verbose=0,
        patience=5  # or 'val_acc' ?
    )),
)

Problem.loss("mse")  # or 'categorical_crossentropy' ?

Problem.metrics(["r2"])  # or 'acc' ?

Problem.objective("r2__max")  # or 'val_acc__last' ?

# Just to print your problem, to test its definition and imports in the current python environment.
if __name__ == "__main__":
    print(Problem)