State Logger

class cooper.state_logger.StateLogger(save_metrics)[source]

Utility for storing optimization metrics (e.g. loss, multipliers) through training.

Parameters

save_metrics (List[str]) – List of metric names to be stored. Currently supported values are: loss, ineq_defect, eq_defect, ineq_multipliers, eq_multipliers.

store_metrics(formulation, step_id, partial_dict=None)[source]

Store a new screenshot of the metrics.

Parameters
  • formulation (Formulation) – Formulation from which to take the current metric values.

  • step_id (int) – Identifier for the optimization step.

  • partial_dict (Optional[dict]) – Auxiliary dictionary with other metrics to be logged, but which are not part of the “canonical” options available in save_metrics. Defaults to None.

unpack_stored_metrics()[source]

Returns a dictionary containing the stored values separated by metric.

Return type

dict