callbacks#

import tensorwaves.optimizer.callbacks

Collection of loggers that can be inserted into an optimizer as callback.

class Loadable[source]#

Bases: ABC

abstract static load_latest_parameters(filename: Path | str) dict[source]#
class Callback[source]#

Bases: ABC

Interface for callbacks such as CSVSummary.

See also

Callbacks

abstract on_optimize_start(logs: dict[str, Any] | None = None) None[source]#
abstract on_optimize_end(logs: dict[str, Any] | None = None) None[source]#
abstract on_iteration_end(iteration: int, logs: dict[str, Any] | None = None) None[source]#
abstract 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:

>>> from tensorwaves.optimizer import Minuit2
>>> optimizer = Minuit2(
...     callback=CallbackList([TFSummary(), YAMLSummary("fit_result.yml")])
... )
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 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)[source]#

Bases: Callback, Loadable

Write current fit parameters and the estimator value to a YAML 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]#