tensorflow/models · error · TypeError
dict value not supported in converting.
Error message
dict value not supported in converting.
What it means
Export guard in Config._export_config: while recursively converting a Config to plain dicts (as_dict), a nested value turned out to be a plain dict — ambiguous with a Config, so the export refuses to guess a conversion. Note the message text ('Unknown type') does not match this dict case in some revisions.
Solutions
- Store nested mappings as Config/ParamsDict instances rather than raw dicts
- Normalize the config tree (override with Config objects) before calling as_dict
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at official/modeling/hyperparams/base_config.py:174 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/fb463051ebcab229.
Report an issue: GitHub.
Appendix: source
Thrown at official/modeling/hyperparams/base_config.py:174
# Deepcopy here is a temporary solution for preserving type in nested
# Config object.
return copy.deepcopy(v)
elif isinstance(v, dict):
return subconfig_type(v)
else:
raise TypeError('Unknown type: {!r}'.format(type(v)))
@classmethod
def _export_config(cls, v):
"""Returns v with Configs converted to dicts, recursively."""
if isinstance(v, cls.IMMUTABLE_TYPES):
return v
elif isinstance(v, cls.SEQUENCE_TYPES):
return type(v)(map(cls._export_config, v))
elif isinstance(v, params_dict.ParamsDict):
return v.as_dict()
elif isinstance(v, dict):
raise TypeError('dict value not supported in converting.')
else:
raise TypeError('Unknown type: {!r}'.format(type(v)))
@classmethod
def _get_subconfig_type(
cls, k, subconfig_type=None
) -> Type[params_dict.ParamsDict]:
"""Get element type by the field name.
Args:
k: the key/name of the field.
subconfig_type: default subconfig_type. If None, it is set to
Config.
Returns:
Config as default. If a type annotation is found for `k`,
1) returns the type of the annotation if it is subtype of ParamsDict;
2) returns the element type if the annotation of `k` is List[SubType]View on GitHub (pinned to e006f5f0d5)