keras-team/keras · error · ValueError
You need to either pass the `bin_boundaries` argument at con
Error message
You need to either pass the `bin_boundaries` argument at construction time or call `adapt(dataset)` before you can start using the `Discretization` layer.
What it means
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.
Source
Thrown at keras/src/layers/preprocessing/discretization.py:281
(input_shape[0],) + tuple(input_shape[2:]) + (depth,)
)
return out_shape
else:
return (depth,)
def compute_output_spec(self, inputs):
output_shape = self.compute_output_shape(inputs.shape)
return backend.KerasTensor(shape=output_shape, dtype=self.output_dtype)
def load_own_variables(self, store):
if len(store) == 1:
# Legacy format case
self.summary = store["0"]
return
def call(self, inputs):
if self.bin_boundaries is None:
raise ValueError(
"You need to either pass the `bin_boundaries` argument at "
"construction time or call `adapt(dataset)` before you can "
"start using the `Discretization` layer."
)
indices = self.backend.numpy.digitize(inputs, self.bin_boundaries)
return numerical_utils.encode_categorical_inputs(
indices,
output_mode=self.output_mode,
depth=len(self.bin_boundaries) + 1,
dtype=self.output_dtype,
sparse=self.sparse,
backend_module=self.backend,
)
def get_config(self):
return {
"bin_boundaries": self.bin_boundaries,View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/preprocessing/discretization.py:281 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/3334a52a53fd5486.
Report an issue: GitHub.