Tune
Perform the tuning using earlier defined Trainers.
- letstune.tune(trainer: EpochTrainer[P], params_number: int, *, dataset: Any = None, rounds: Sequence[timedelta] | dict[str, Any] | None = None, results_dir: Path | str | None = None, passthrough_errors: bool = False, verbose: bool = True) TuningResults[P]
- letstune.tune(trainer: SimpleTrainer[P], params_number: int, *, dataset: Any = None, results_dir: Path | str | None = None, passthrough_errors: bool = False, verbose: bool = True) TuningResults[P]
Do tuning on this computer (in this Python interpreter) with given
trainerand return tuning results.Params number
Parameter
params_numberdeclares target number of parameters and trainings.§
If
results_diralready has k parameters, thenparams_number- k will be generated.True number of trainings can be less than
params_numberdue to parameter deduplication.Dataset
Parameter
datasetis passed-through toletstune.SimpleTrainer.load_dataset()andletstune.EpochTrainer.load_dataset().Rounds
Only for
letstune.EpochTrainer.Parameter
roundssets durations of rounds.rounds can be set to a
listofdatetime.timedelta:rounds = [ timedelta(minutes=1), timedelta(minutes=2), timedelta(minutes=4), ]
roundsalso accepts adict:rounds = { 'round_durations': [ timedelta(minutes=1), timedelta(minutes=2), timedelta(minutes=4), ], }
The dict accepts
trainings_reductionkey:rounds = { 'round_durations': [ timedelta(minutes=1), timedelta(minutes=2), timedelta(minutes=4), ], 'trainings_reduction': 2.0, }
To the next round are promoted top
ceil(trainings_number / trainings_reduction)trainings.The default value for
trainings_reductionis4.0.Results directory
Parameter
results_dirsets the directory, where tuning results will be stored.Directory contents:
letstune.dbis an SQLite database with training metadata,checkpointsis a directory with serialized trained models.
If
results_diris not given, then directoryltrunsis created, which will contain the results.Passthrough errors
When
passthrough_errorsisTrue, then all exceptions are not caught.Otherwise, they will be noted in tuning results and training will continue. That’s the default option.
Verbose
If
verboseisTrue, then explanatory log messages will be printed to the standard output. That’s the default option.Returned tuning results
The type of returned tuning results depends on the type of
trainerparameter.When given
letstune.SimpleTrainer[P], thenletstune.results.simple.TuningResults[P] will be returned.When given
letstune.EpochTrainer[P], thenletstune.results.epoch.TuningResults[P] will be returned.Facade
This function is a facade to the letstune system - it is usually a good choice.
If you need further customization, consider to copy this function and modify it according to your needs.