- class optuna.integration.AllenNLPExecutor(trial, config_file, serialization_dir, metrics='best_validation_accuracy', *, include_package=None, force=False, file_friendly_logging=False)
AllenNLP extension to use optuna with Jsonnet config file.
See the examples of objective function.
You can also see the tutorial of our AllenNLP integration on AllenNLP Guide.
From Optuna v2.1.0, users have to cast their parameters by using methods in Jsonnet. Call
std.parseIntfor integer, or
std.parseJsonfor floating point. Please see the example configuration.
AllenNLPExecutor, you can pass parameters to AllenNLP by either defining a search space using Optuna suggest methods or setting environment variables just like AllenNLP CLI. If a value is set in both a search space in Optuna and the environment variables, the executor will use the value specified in the search space in Optuna.
serialization_dir (str) – A path which model weights and logs are saved.
metrics (str) – An evaluation metric. GradientDescrentTrainer.train() of AllenNLP returns a dictionary containing metrics after training.
AllenNLPExecutoraccesses the dictionary by the key
metricsyou specify and use it as a objective value.
Added in v1.4.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v1.4.0.
Train a model using AllenNLP.