MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / flatten_dict

Function flatten_dict

monai/utils/misc.py:930–940  ·  view source on GitHub ↗

Flatten the nested dictionary to a flat dictionary.

(metrics: dict[str, Any])

Source from the content-addressed store, hash-verified

928
929
930def flatten_dict(metrics: dict[str, Any]) -> dict[str, Any]:
931 """
932 Flatten the nested dictionary to a flat dictionary.
933 """
934 result = {}
935 for key, value in metrics.items():
936 if isinstance(value, dict):
937 result.update(flatten_dict(value))
938 else:
939 result[key] = value
940 return result

Callers 2

_default_epoch_printMethod · 0.90
_log_metricsMethod · 0.90

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…