State Logger

class cooper.utils.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(cmp_state, step_id, partial_dict=None)[source]

Store a new screenshot of the metrics.

Parameters
  • cmp_state (CMPState) – State of the CMP to be stored.

  • 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