tensorflow/models · error · KeyError
The value extracted with keys: %s is not a leaf of the dicti
Error message
The value extracted with keys: %s is not a leaf of the dictionary: %s.
What it means
Error "The value extracted with keys: %s is not a leaf of the dictionary: %s." thrown in tensorflow/models.
Source
Thrown at official/core/train_utils.py:66
d: The dictionary to extract value from.
keys: The list of keys to extract values recursively.
Returns:
The value of the leaf.
Raises:
KeyError: If the value of keys extracted is a dictionary.
"""
leaf = d
for k in keys:
if not isinstance(leaf, dict) or k not in leaf:
raise KeyError(
'Path not exist while traversing the dictionary: d with keys'
': %s.' % keys)
leaf = leaf[k]
if isinstance(leaf, dict):
raise KeyError('The value extracted with keys: %s is not a leaf of the '
'dictionary: %s.' % (keys, d))
return leaf
def cast_leaf_nested_dict(d: Dict[str, Any],
cast_fn: Callable[[Any], Any]) -> Dict[str, Any]:
"""Cast the leaves of a dictionary with arbitrary depth in place.
Args:
d: The dictionary to extract value from.
cast_fn: The casting function.
Returns:
A dictionray with the same structure as d.
"""
for key, value in d.items():
if isinstance(value, dict):
d[key] = cast_leaf_nested_dict(value, cast_fn)View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/core/train_utils.py:66 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/a166a97c4dad4ba2.
Report an issue: GitHub.