optuna.integration.FastAIPruningCallback¶
-
class
optuna.integration.
FastAIPruningCallback
(learn: Learner, trial: optuna.trial.Trial, monitor: str)[source]¶ FastAI callback to prune unpromising trials for fastai.
Note
This callback is for fastai<2.0, not the coming version developed in fastai/fastai_dev.
See the example if you want to add a pruning callback which monitors validation loss of a
Learner
.Example
Register a pruning callback to
learn.fit
andlearn.fit_one_cycle
.learn.fit(n_epochs, callbacks=[FastAIPruningCallback(learn, trial, 'valid_loss')]) learn.fit_one_cycle( n_epochs, cyc_len, max_lr, callbacks=[FastAIPruningCallback(learn, trial, 'valid_loss')])
- Parameters
learn – fastai.basic_train.Learner.
trial – A
Trial
corresponding to the current evaluation of the objective function.monitor – An evaluation metric for pruning, e.g.
valid_loss
andAccuracy
. Please refer to fastai.Callback reference for further details.
-
__init__
(learn: Learner, trial: optuna.trial.Trial, monitor: str) → None[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(learn, trial, monitor)Initialize self.
on_epoch_end
(epoch, **kwargs)