keras-team/keras · error · ValueError
Improper config format for {config}. Expecting python dict c
Error message
Improper config format for {config}. Expecting python dict contains `class_name` and `config` as keys What it means
Error "Improper config format for {config}. Expecting python dict contains `class_name` and `config` as keys" thrown in keras-team/keras.
Source
Thrown at keras/src/legacy/saving/serialization.py:343
f"Cannot serialize {instance} because it doesn't implement "
"`get_config()`."
)
def class_and_config_for_serialized_keras_object(
config,
module_objects=None,
custom_objects=None,
printable_module_name="object",
):
"""Returns the class name and config for a serialized keras object."""
if (
not isinstance(config, dict)
or "class_name" not in config
or "config" not in config
):
raise ValueError(
f"Improper config format for {config}. "
"Expecting python dict contains `class_name` and `config` as keys"
)
class_name = config["class_name"]
cls = object_registration.get_registered_object(
class_name, custom_objects, module_objects
)
if cls is None:
raise ValueError(
f"Unknown {printable_module_name}: '{class_name}'. "
"Please ensure you are using a `keras.utils.custom_object_scope` "
"and that this object is included in the scope. See "
"https://www.tensorflow.org/guide/keras/save_and_serialize"
"#registering_the_custom_object for details."
)
cls_config = config["config"]View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/legacy/saving/serialization.py:343 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/040196c37b157c99.
Report an issue: GitHub.