{"record":{"id":"6c6c51dc7e22188d","repo":"keras-team/keras","slug":"sequential-model-self-name-cannot-be-built-becau","errorCode":null,"errorMessage":"Sequential model {self.name} cannot be built because it has no layers. Call `model.add(layer)`.","messagePattern":"Sequential model (.+?) cannot be built because it has no layers\\. Call `model\\.add\\(layer\\)`\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/models/sequential.py","lineNumber":172,"sourceCode":"            input_shape = self._layers[0].input_shape\n            self.build(input_shape)\n\n    def _lock_state(self):\n        # Unlike other layers, Sequential is mutable after build.\n        pass\n\n    def _obj_type(self):\n        return \"Sequential\"\n\n    def build(self, input_shape=None):\n        try:\n            input_shape = standardize_shape(input_shape)\n        except:\n            # Do not attempt to build if the model does not have a single\n            # input tensor.\n            return\n        if not self._layers:\n            raise ValueError(\n                f\"Sequential model {self.name} cannot be built because it has \"\n                \"no layers. Call `model.add(layer)`.\"\n            )\n        if isinstance(self._layers[0], InputLayer):\n            if self._layers[0].batch_shape != input_shape:\n                raise ValueError(\n                    f\"Sequential model '{self.name}' has already been \"\n                    \"configured to use input shape \"\n                    f\"{self._layers[0].batch_shape}. You cannot build it \"\n                    f\"with input_shape {input_shape}\"\n                )\n        else:\n            dtype = self._layers[0].compute_dtype\n            self._layers = [\n                InputLayer(batch_shape=input_shape, dtype=dtype)\n            ] + self._layers\n\n        # Build functional model","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/models/sequential.py#L154-L190","documentation":"Error \"Sequential model {self.name} cannot be built because it has no layers. Call `model.add(layer)`.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/models/sequential.py:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}