keras-team/keras · error · TypeError
`model_from_config` expects a dictionary, not a list…
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
Raised by model_from_config when the config argument is a list. Lists of layer configs are the serialization format of Sequential models, which must be reconstructed via Sequential.from_config; the generic path only accepts the dict config produced by model.get_config() for Functional/Model classes.
Solutions
- Use keras.Sequential.from_config(config) when config is a list of layer configs
- Pass the dict returned by model.get_config() for Functional/ subclass models
Defensive patterns
Strategy: type-guard
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.
Appendix: 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)