{"record":{"id":"80a425a7447cfcb6","repo":"keras-team/keras","slug":"sequential-model-self-name-has-no-defined-inpu-80a425","errorCode":null,"errorMessage":"Sequential model '{self.name}' has no defined inputs yet.","messagePattern":"Sequential model '(.+?)' has no defined inputs yet\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"keras/src/models/sequential.py","lineNumber":318,"sourceCode":"        if self._functional:\n            return self._functional.input_shape\n        raise AttributeError(\n            f\"Sequential model '{self.name}' has no defined input shape yet.\"\n        )\n\n    @property\n    def output_shape(self):\n        if self._functional:\n            return self._functional.output_shape\n        raise AttributeError(\n            f\"Sequential model '{self.name}' has no defined output shape yet.\"\n        )\n\n    @property\n    def inputs(self):\n        if self._functional:\n            return self._functional.inputs\n        raise AttributeError(\n            f\"Sequential model '{self.name}' has no defined inputs yet.\"\n        )\n\n    @property\n    def outputs(self):\n        if self._functional:\n            return self._functional.outputs\n        raise AttributeError(\n            f\"Sequential model '{self.name}' has no defined outputs yet.\"\n        )\n\n    @property\n    def input_dtype(self):\n        # Sequential.__call__ will try to convert its inputs\n        # to the dtype expected by its input layer, if any.\n        layers = self._layers\n        if layers and isinstance(layers[0], InputLayer):\n            return layers[0].dtype","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/models/sequential.py#L300-L336","documentation":"Returned error text when accessing input_shape/inputs-related properties on a Sequential model that has not been built and has no Input layer or input_shape defined, so the input specification is not yet known.","triggerScenarios":"model = keras.Sequential(); model.inputs before any build/InputLayer","commonSituations":"Keras 3 migrations where code assumed graph-mode inputs were always available","solutions":["Build the model first","Construct with an explicit Input layer","Derive inputs yourself from your data pipeline if the model is unbuilt"],"exampleFix":"# before\nins = model.inputs\n\n# after\nmodel.build((None, 28, 28))\nins = model.inputs","handlingStrategy":"try-catch","validationCode":"has_inputs = bool(model._functional)","typeGuard":null,"tryCatchPattern":"try:\n    ins = model.inputs\nexcept AttributeError:\n    model.build(input_shape)\n    ins = model.inputs","preventionTips":["Define the input with keras.Input before accessing .inputs","Build the model before introspection"],"tags":["keras","sequential","inputs","lazy-build"],"backgroundTag":"model-not-built","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}