Skip to content

Commit

Permalink
Use pruner in executor
Browse files Browse the repository at this point in the history
  • Loading branch information
himkt committed Sep 17, 2020
1 parent 0c4e5bd commit b6dfc4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion allennlp/allennlp_jsonnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ def objective(trial):
if version.parse(allennlp.__version__) < version.parse("1.0.0"):
raise RuntimeError("AllenNLP>=1.0.0 is required for this example.")

study = optuna.create_study(direction="maximize")
study = optuna.create_study(
direction="maximize",
storage="sqlite:///allennlp.db",
pruner=optuna.pruners.HyperbandPruner(),
)
study.optimize(objective, n_trials=50, timeout=600)

print("Number of finished trials: ", len(study.trials))
Expand Down
5 changes: 5 additions & 0 deletions allennlp/classifier.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,10 @@ local ENCODER = CNN_FIELDS(
},
patience: 2,
validation_metric: '+accuracy',
epoch_callbacks: [
{
type: 'optuna_pruner',
},
],
},
}

0 comments on commit b6dfc4e

Please sign in to comment.