예제 #1
0
def objective(trial):
    trial.suggest_uniform("DROPOUT", 0.0, 0.5)
    trial.suggest_int("EMBEDDING_DIM", 20, 50)
    trial.suggest_int("MAX_FILTER_SIZE", 3, 6)
    trial.suggest_int("NUM_FILTERS", 16, 32)
    trial.suggest_int("HIDDEN_SIZE", 16, 32)

    serialization_dir = os.path.join(MODEL_DIR, "test_{}".format(trial.number))
    executor = AllenNLPExecutor(trial, CONFIG_PATH, serialization_dir)

    return executor.run()
예제 #2
0
def objective(trial):
    trial.suggest_uniform("DROPOUT", 0.0, 0.5)
    trial.suggest_int("EMBEDDING_DIM", 20, 50)
    trial.suggest_int("MAX_FILTER_SIZE", 3, 6)
    trial.suggest_int("NUM_FILTERS", 16, 32)
    trial.suggest_int("HIDDEN_SIZE", 16, 32)

    config_path = os.path.join(EXAMPLE_DIR, "classifier.jsonnet")
    serialization_dir = os.path.join(MODEL_DIR, "test_{}".format(trial.number))
    executor = AllenNLPExecutor(trial, config_path, serialization_dir)
    return executor.run()
예제 #3
0
파일: hpo.py 프로젝트: himkt/allennlp-NER
def objective(trial: Trial):
    trial.suggest_int("char_embedding_dim", 16, 128)
    trial.suggest_int("lstm_hidden_size", 64, 256)
    trial.suggest_float("lr", 5e-3, 5e-1, log=True)

    executor = AllenNLPExecutor(
        trial=trial,
        config_file=config_file,
        serialization_dir=f"result/{trial.number}",
        metrics="best_validation_f1-measure-overall",
        include_package="allennlp_models",
    )
    return executor.run()
예제 #4
0
    def _objective(
        trial: Trial,
        hparam_path: str,
    ) -> float:

        for hparam in json.load(open(hparam_path)):
            attr_type = hparam["type"]
            suggest = getattr(trial, "suggest_{}".format(attr_type))
            suggest(**hparam["attributes"])

        optuna_serialization_dir = os.path.join(
            serialization_dir, "trial_{}".format(trial.number))
        executor = AllenNLPExecutor(
            trial,
            config_file,
            optuna_serialization_dir,
            metrics=metrics,
            include_package=include_package,
        )
        return executor.run()