-
-
Notifications
You must be signed in to change notification settings - Fork 692
Add the logging of dict metrics #3294
Description
🚀 Feature
The request would be to add the logging of Mapping metrics in the logging framework.
The ignite.metrics.Metric class supports the use of Mapping metrics as we can see below. However, the BaseOutputHandler does not support dictionary metrics and warns about them.
ignite/ignite/metrics/metric.py
Lines 488 to 494 in edd5025
| if isinstance(result, Mapping): | |
| if name in result.keys(): | |
| raise ValueError(f"Argument name '{name}' is conflicting with mapping keys: {list(result.keys())}") | |
| for key, value in result.items(): | |
| engine.state.metrics[key] = value | |
| engine.state.metrics[name] = result |
Ones can simply ask the logger to report the metric names produced by the Metric directly as those will be store in the metric state no matter which name was used for the metric. But I feel like it breaks the kind of "namespaces" that seems to be used in loggers.
I would find it practical if the logger could handle mappings and log their content as sub values of the metric itself.
This could be achieved by editing the BaseOutputHandler which would fix this issue in any existing logger. There should not be any side effect as the logger was warning users if using mappings, so I imagine very few users were already having a mapping metrics logged that would now appear if they upgraded to a version with this feature.