{"record":{"id":"d48eab9a187c2572","repo":"keras-team/keras","slug":"all-layers-added-to-a-sequential-model-should-have","errorCode":null,"errorMessage":"All layers added to a Sequential model should have unique names. Name '{layer.name}' is already the name of a layer in this model. Update the `name` argument to pass a unique name.","messagePattern":"All layers added to a Sequential model should have unique names\\. Name '(.+?)' is already the name of a layer in this model\\. Update the `name` argument to pass a unique name\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/models/sequential.py","lineNumber":103,"sourceCode":"        # use it to build an InputLayer.\n        if not self._layers:\n            if getattr(layer, \"_input_shape_arg\", None) is not None:\n                self.add(InputLayer(shape=layer._input_shape_arg))\n\n        # If we are passed a Keras tensor created by keras.Input(), we\n        # extract the input layer from its keras history and use that.\n        if hasattr(layer, \"_keras_history\"):\n            origin_layer = layer._keras_history[0]\n            if isinstance(origin_layer, InputLayer):\n                layer = origin_layer\n        if not isinstance(layer, Layer):\n            raise ValueError(\n                \"Only instances of `keras.Layer` can be \"\n                f\"added to a Sequential model. Received: {layer} \"\n                f\"(of type {type(layer)})\"\n            )\n        if not self._is_layer_name_unique(layer):\n            raise ValueError(\n                \"All layers added to a Sequential model \"\n                f\"should have unique names. Name '{layer.name}' is already \"\n                \"the name of a layer in this model. Update the `name` argument \"\n                \"to pass a unique name.\"\n            )\n        if (\n            isinstance(layer, InputLayer)\n            and self._layers\n            and isinstance(self._layers[0], InputLayer)\n        ):\n            raise ValueError(\n                f\"Sequential model '{self.name}' has already been configured \"\n                f\"to use input shape {self._layers[0].batch_shape}. You cannot \"\n                f\"add a different Input layer to it.\"\n            )\n\n        self._layers.append(layer)\n        if rebuild:","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/models/sequential.py#L85-L121","documentation":"Error \"All layers added to a Sequential model should have unique names. Name '{layer.name}' is already the name of a layer in this model. Update the `name` argument to pass a unique name.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/models/sequential.py:103 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"}