{"record":{"id":"3cb47082d7d1bbbe","repo":"keras-team/keras","slug":"a-sequential-model-configuration-must-be-a-diction","errorCode":null,"errorMessage":"A Sequential model configuration must be a dictionary containing the 'name' and 'layers' keys. Received: config={config}","messagePattern":"A Sequential model configuration must be a dictionary containing the 'name' and 'layers' keys\\. Received: config=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/models/sequential.py","lineNumber":369,"sourceCode":"        for layer in super().layers:\n            # `super().layers` include the InputLayer if available (it is\n            # filtered out of `self.layers`).\n            layer_configs.append(serialize_fn(layer))\n        config = Model.get_config(self)\n        config[\"name\"] = self.name\n        config[\"layers\"] = copy.deepcopy(layer_configs)\n        if self._functional is not None:\n            config[\"build_input_shape\"] = self._layers[0].batch_shape\n        return config\n\n    @classmethod\n    def from_config(cls, config, custom_objects=None):\n        if \"name\" in config:\n            name = config[\"name\"]\n            build_input_shape = config.get(\"build_input_shape\")\n            layer_configs = config[\"layers\"]\n        else:\n            raise ValueError(\n                \"A Sequential model configuration must be \"\n                \"a dictionary containing the 'name' and \"\n                f\"'layers' keys. Received: config={config}\"\n            )\n        model = cls(name=name)\n        for layer_config in layer_configs:\n            if \"module\" not in layer_config:\n                # Legacy format deserialization (no \"module\" key)\n                # used for H5 and SavedModel formats\n                layer = saving_utils.model_from_config(\n                    layer_config,\n                    custom_objects=custom_objects,\n                )\n            else:\n                layer = serialization_lib.deserialize_keras_object(\n                    layer_config,\n                    custom_objects=custom_objects,\n                )","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/models/sequential.py#L351-L387","documentation":"Sequential.from_config expects the dict produced by get_config(), which must include 'name' and 'layers'. A dict lacking 'name' is treated as an invalid configuration and rejected.","triggerScenarios":"keras.Sequential.from_config({'layers': [...]}) or from_config with an unexpected structure","commonSituations":"Loading hand-edited JSON, YAML-derived dicts, or configs from a different serialization format or Keras version","solutions":["Use the dict from model.get_config() unmodified","Add the missing 'name' (and keep 'layers') keys before calling from_config","For bare layer lists, pass the list form that from_config also accepts"],"exampleFix":"# before\nmodel = keras.Sequential.from_config({'layers': [...]})\n\n# after\ncfg = {'name': 'sequential_1', 'layers': [...]}\nmodel = keras.Sequential.from_config(cfg)","handlingStrategy":"validation","validationCode":"def is_sequential_config(cfg):\n    return (isinstance(cfg, dict) and 'name' in cfg\n            and isinstance(cfg.get('layers'), list))","typeGuard":null,"tryCatchPattern":"try:\n    model = keras.Sequential.from_config(cfg)\nexcept ValueError:\n    if 'name' not in cfg or 'layers' not in cfg:\n        raise\n    cfg.setdefault('name', 'sequential')\n    model = keras.Sequential.from_config(cfg)","preventionTips":["Load round-trip artifacts produced by the same to_json/get_config API","Validate the config dict before calling from_config"],"tags":["keras","sequential","from-config","serialization"],"backgroundTag":"config-validation-failed","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}