otx.api.entities.train_parameters#

This module implements the TrainingParameters entity.

Functions

default_progress_callback(progress[, score])

Default progress callback.

default_save_model_callback()

Default save model callback.

Classes

TrainParameters(resume, update_progress, ...)

Train parameters.

UpdateProgressCallback(*args, **kwargs)

UpdateProgressCallback protocol.

class otx.api.entities.train_parameters.TrainParameters(resume: bool = False, update_progress: ~typing.Callable[[int, float | None], ~typing.Any] = <function default_progress_callback>, save_model: ~typing.Callable[[], None] = <function default_save_model_callback>)[source]#

Bases: object

Train parameters.

resume#

Set to True if training must be resume with the optimizer state; set to False to discard the optimizer state and start with fresh optimizer

Type:

bool

update_progress#

Callback which can be used to provide updates about the progress of a task.

Type:

Callable[[int, float | None], Any]

save_model#

Callback to notify that the model weights have been changed. This callback can be used by the task when temporary weights should be saved (for instance, at the end of an epoch). If this callback has been used to save temporary weights, those weights will be used to resume training if for some reason training was suspended.

Type:

Callable[[], None]

save_model()#

Default save model callback. It is a placeholder (does nothing) and is used in empty TrainParameters.

update_progress(score: float | None = None)#

Default progress callback. It is a placeholder (does nothing) and is used in empty TrainParameters.

class otx.api.entities.train_parameters.UpdateProgressCallback(*args, **kwargs)[source]#

Bases: Protocol

UpdateProgressCallback protocol.

Used as a replacement of Callable[] type since Callable doesn’t handle default parameters like score: Optional[float] = None

__call__(progress: float, score: float | None = None)[source]#

Callback to provide updates about the progress of a task.

It is recommended to call this function at least once per epoch. However, the exact frequency is left to the task implementer.

An optional score can also be passed. If specified, this score can be used by HPO to monitor the improvement of the task.

Parameters:
  • progress – Progress as a percentage

  • score – Optional validation score

otx.api.entities.train_parameters.default_progress_callback(progress: float, score: float | None = None)[source]#

Default progress callback. It is a placeholder (does nothing) and is used in empty TrainParameters.

otx.api.entities.train_parameters.default_save_model_callback()[source]#

Default save model callback. It is a placeholder (does nothing) and is used in empty TrainParameters.