keras-team/keras · error · ValueError

Saved configuration not understood. Configuration should be…

Error message

Saved configuration not understood. Configuration should be a dictionary, string, tuple or list. Received: config={config}.

What it means

Raised by _deserialize_nested_config when a config fragment is not one of the supported types: None, a single serialized object, a dict, a tuple, or a list. The recursive deserializer dispatches on the fragment's Python type, so anything else (e.g. a set, a number used as a config, or a corrupted value) is rejected.

Solutions

  1. Fix the offending config fragment so it is a dict, list, tuple, string, or a serialized-object representation
  2. Regenerate the config via serialize_keras_object / get_config instead of hand-editing it
  3. Check that custom objects' get_config() returns JSON-serializable builtin types
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at keras/src/legacy/saving/saving_utils.py:219 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/65b9f3550e8d44a8. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/legacy/saving/saving_utils.py:219

        if isinstance(obj, str):
            return True  # Serialized function or string.
        return False

    if config is None:
        return None
    if _is_single_object(config):
        return deserialize_fn(config)
    elif isinstance(config, dict):
        return {
            k: _deserialize_nested_config(deserialize_fn, v)
            for k, v in config.items()
        }
    elif isinstance(config, (tuple, list)):
        return [
            _deserialize_nested_config(deserialize_fn, obj) for obj in config
        ]

    raise ValueError(
        "Saved configuration not understood. Configuration should be a "
        f"dictionary, string, tuple or list. Received: config={config}."
    )


def _deserialize_metric(metric_config):
    """Deserialize metrics, leaving special strings untouched."""
    if metric_config in ["accuracy", "acc", "crossentropy", "ce"]:
        # Do not deserialize accuracy and cross-entropy strings as we have
        # special case handling for these in compile, based on model output
        # shape.
        return metric_config
    return metrics_module.deserialize(metric_config)


def _resolve_compile_arguments_compat(obj, obj_config, module):
    """Resolves backwards compatibility issues with training config arguments.

View on GitHub (pinned to 7a34a03db6)