keras-team/keras · error · TypeError

`model_from_config` expects a dictionary, not a list. Receiv

Error message

`model_from_config` expects a dictionary, not a list. Received: config={config}. Did you meant to use `Sequential.from_config(config)`?

What it means

Error "`model_from_config` expects a dictionary, not a list. Received: config={config}. Did you meant to use `Sequential.from_config(config)`?" thrown in keras-team/keras.

Source

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


def model_from_config(config, custom_objects=None):
    """Instantiates a Keras model from its config.

    Args:
        config: Configuration dictionary.
        custom_objects: Optional dictionary mapping names
            (strings) to custom classes or functions to be
            considered during deserialization.

    Returns:
        A Keras model instance (uncompiled).

    Raises:
        TypeError: if `config` is not a dictionary.
    """
    if isinstance(config, list):
        raise TypeError(
            "`model_from_config` expects a dictionary, not a list. "
            f"Received: config={config}. Did you meant to use "
            "`Sequential.from_config(config)`?"
        )

    global MODULE_OBJECTS

    if not hasattr(MODULE_OBJECTS, "ALL_OBJECTS"):
        from keras.src import layers
        from keras.src import models

        MODULE_OBJECTS.ALL_OBJECTS = layers.__dict__
        MODULE_OBJECTS.ALL_OBJECTS["InputLayer"] = layers.InputLayer
        MODULE_OBJECTS.ALL_OBJECTS["Functional"] = models.Functional
        MODULE_OBJECTS.ALL_OBJECTS["Model"] = models.Model
        MODULE_OBJECTS.ALL_OBJECTS["Sequential"] = models.Sequential

    if not isinstance(config, dict) or "config" not in config:

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/legacy/saving/saving_utils.py:39 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/06d6ac91d01e39fe. Report an issue: GitHub.