callbacks
Collection of loggers that can be inserted into an optimizer as callback.
-
class Loadable[source]
Bases: ABC
-
abstractmethod static load_latest_parameters(filename: Path | str) → dict[source]
-
class Callback[source]
Bases: ABC
Interface for callbacks such as CSVSummary.
-
abstractmethod on_optimize_start(logs: dict[str, Any] | None = None) → None[source]
-
abstractmethod on_optimize_end(logs: dict[str, Any] | None = None) → None[source]
-
abstractmethod on_iteration_end(iteration: int, logs: dict[str, Any] | None = None) → None[source]
-
abstractmethod on_function_call_end(function_call: int, logs: dict[str, Any] | None = None) → None[source]
-
class CallbackList(callbacks: Iterable[Callback])[source]
Bases: Callback
Class for combining Callback s.
Combine different Callback classes in to a chain as follows:
-
property callbacks: list[Callback][source]
-
on_optimize_start(logs: dict[str, Any] | None = None) → None[source]
-
on_optimize_end(logs: dict[str, Any] | None = None) → None[source]
-
on_iteration_end(iteration: int, logs: dict[str, Any] | None = None) → None[source]
-
on_function_call_end(function_call: int, logs: dict[str, Any] | None = None) → None[source]
-
class RichProgressBar(*columns: str | ProgressColumn, total: int | None = None, **progress_kwargs: Any)[source]
Bases: Callback
Display a rich progress bar during optimization.
- Parameters:
*columns – The columns to display in the progress bar. If
not provided, a default set of columns will be used.
**progress_kwargs – Keyword arguments forwarded to rich.progress.Progress.
total – The expected total number of function calls to be made during
optimization in order to get a time estimate.
-
on_optimize_start(logs: dict[str, Any] | None = None) → None[source]
-
on_optimize_end(logs: dict[str, Any] | None = None) → None[source]
-
on_iteration_end(iteration: int, logs: dict[str, Any] | None = None) → None[source]
-
on_function_call_end(function_call: int, logs: dict[str, Any] | None = None) → None[source]
-
class TqdmProgressBar(**tqdm_kwargs: Any)[source]
Bases: Callback
Display a tqdm progress bar during optimization.
- Parameters:
**tqdm_kwargs – Keyword arguments forwarded to tqdm.
-
on_optimize_start(logs: dict[str, Any] | None = None) → None[source]
-
on_optimize_end(logs: dict[str, Any] | None = None) → None[source]
-
on_iteration_end(iteration: int, logs: dict[str, Any] | None = None) → None[source]
-
on_function_call_end(function_call: int, logs: dict[str, Any] | None = None) → None[source]
-
class CSVSummary(filename: Path | str, function_call_step_size: int = 1, iteration_step_size: int = 1)[source]
Bases: Callback, Loadable
Log fit parameters and the estimator value to a CSV file.
-
on_optimize_start(logs: dict[str, Any] | None = None) → None[source]
-
on_optimize_end(logs: dict[str, Any] | None = None) → None[source]
-
on_iteration_end(iteration: int, logs: dict[str, Any] | None = None) → None[source]
-
on_function_call_end(function_call: int, logs: dict[str, Any] | None = None) → None[source]
-
static load_latest_parameters(filename: Path | str) → dict[source]
-
class TFSummary(logdir: str = 'logs', step_size: int = 10, subdir: str | None = None)[source]
Bases: Callback
Log fit parameters and the estimator value to a tf.summary.
The logs can be viewed with TensorBoard
via:
tensorboard --logdir logs
-
on_optimize_start(logs: dict[str, Any] | None = None) → None[source]
-
on_optimize_end(logs: dict[str, Any] | None = None) → None[source]
-
on_iteration_end(iteration: int, logs: dict[str, Any] | None = None) → None[source]
-
on_function_call_end(function_call: int, logs: dict[str, Any] | None = None) → None[source]
-
class YAMLSummary(filename: Path | str, step_size: int = 10, git_friendly: bool = False)[source]
Bases: Callback, Loadable
Write current fit parameters and the estimator value to a YAML file.
- Parameters:
filename – The name of output YAML file to write the logs to.
step_size – The number of function calls between each log entry.
git_friendly – If True, entries that are differ per run in reproducible fits,
such as time, are omitted from the log.
-
on_optimize_start(logs: dict[str, Any] | None = None) → None[source]
-
on_optimize_end(logs: dict[str, Any] | None = None) → None[source]
-
on_iteration_end(iteration: int, logs: dict[str, Any] | None = None) → None[source]
-
on_function_call_end(function_call: int, logs: dict[str, Any] | None = None) → None[source]
-
static load_latest_parameters(filename: Path | str) → dict[source]