{"record":{"id":"85221fca722a163e","repo":"keras-team/keras","slug":"sequential-model-self-name-has-no-defined-outp-85221f","errorCode":null,"errorMessage":"Sequential model '{self.name}' has no defined outputs yet.","messagePattern":"Sequential model '(.+?)' has no defined outputs yet\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"keras/src/models/sequential.py","lineNumber":326,"sourceCode":"        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\n        return super().input_dtype\n\n    def _is_layer_name_unique(self, layer):\n        for ref_layer in self._layers:\n            if layer.name == ref_layer.name and ref_layer is not layer:\n                return False\n        return True\n","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/models/sequential.py#L308-L344","documentation":"outputs returns the graph's output tensors; they exist only after the functional graph is materialized. Accessing it earlier raises AttributeError.","triggerScenarios":"Reading model.outputs on an unbuilt Sequential","commonSituations":"Grad-CAM style hooks, feature extraction code, or introspection before training","solutions":["Build the model or run one forward pass","Add an InputLayer to define the graph eagerly","Use compute_output_spec/compute_output_shape for symbolic probing"],"exampleFix":"# before\nouts = model.outputs\n\n# after\nmodel.build((None, 28, 28))\nouts = model.outputs","handlingStrategy":"try-catch","validationCode":"has_outputs = bool(model._functional)","typeGuard":null,"tryCatchPattern":"try:\n    outs = model.outputs\nexcept AttributeError:\n    model.build(input_shape)\n    outs = model.outputs","preventionTips":["Build the model before accessing .outputs","Use model(x) once to build lazily"],"tags":["keras","sequential","outputs","lazy-build"],"backgroundTag":"model-not-built","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}