diff --git a/tmpl/utils/tabular_logger.py b/tmpl/utils/tabular_logger.py index eccb098..fb8eae7 100644 --- a/tmpl/utils/tabular_logger.py +++ b/tmpl/utils/tabular_logger.py @@ -29,9 +29,9 @@ def log_metrics(self, metrics_dict: Dict[str, float], step: Optional[int] = None def metrics2str(metrics: dict) -> str: return ', '.join([ - '{}: {{{}}}'.format(x, metrics2str(y)) if isinstance(y, dict) else - '{}: {:.5f}'.format(x, y) if isinstance(y, float) else '{}: {}'.format(x, y) - for x, y in metrics.items() + f'{x}: {{{metrics2str(y)}}}' if isinstance(y, dict) else + (f'{x}: {y:.4f}' if y >= 1e-4 else f'{x}: {y:.5f}') + if isinstance(y, float) else f'{x}: {y}' for x, y in metrics.items() ]) log_str = metrics2str(metrics)