{"record":{"id":"3334a52a53fd5486","repo":"keras-team/keras","slug":"you-need-to-either-pass-the-bin-boundaries-argum","errorCode":null,"errorMessage":"You need to either pass the `bin_boundaries` argument at construction time or call `adapt(dataset)` before you can start using the `Discretization` layer.","messagePattern":"You need to either pass the `bin_boundaries` argument at construction time or call `adapt\\(dataset\\)` before you can start using the `Discretization` layer\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/discretization.py","lineNumber":281,"sourceCode":"                    (input_shape[0],) + tuple(input_shape[2:]) + (depth,)\n                )\n                return out_shape\n            else:\n                return (depth,)\n\n    def compute_output_spec(self, inputs):\n        output_shape = self.compute_output_shape(inputs.shape)\n        return backend.KerasTensor(shape=output_shape, dtype=self.output_dtype)\n\n    def load_own_variables(self, store):\n        if len(store) == 1:\n            # Legacy format case\n            self.summary = store[\"0\"]\n        return\n\n    def call(self, inputs):\n        if self.bin_boundaries is None:\n            raise ValueError(\n                \"You need to either pass the `bin_boundaries` argument at \"\n                \"construction time or call `adapt(dataset)` before you can \"\n                \"start using the `Discretization` layer.\"\n            )\n\n        indices = self.backend.numpy.digitize(inputs, self.bin_boundaries)\n        return numerical_utils.encode_categorical_inputs(\n            indices,\n            output_mode=self.output_mode,\n            depth=len(self.bin_boundaries) + 1,\n            dtype=self.output_dtype,\n            sparse=self.sparse,\n            backend_module=self.backend,\n        )\n\n    def get_config(self):\n        return {\n            \"bin_boundaries\": self.bin_boundaries,","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/discretization.py#L263-L299","documentation":"Error \"You need to either pass the `bin_boundaries` argument at construction time or call `adapt(dataset)` before you can start using the `Discretization` layer.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/discretization.py:281 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"}