keras-team/keras · error · ValueError
`count_weights` is not used when `output_mode` is not `'coun
Error message
`count_weights` is not used when `output_mode` is not `'count'`. Received `count_weights={count_weights}`. What it means
Error "`count_weights` is not used when `output_mode` is not `'count'`. Received `count_weights={count_weights}`." thrown in keras-team/keras.
Source
Thrown at keras/src/layers/preprocessing/category_encoding.py:159
def compute_output_spec(self, inputs, count_weights=None):
output_shape = self.compute_output_shape(inputs.shape)
return KerasTensor(
output_shape, dtype=self.compute_dtype, sparse=self.sparse
)
def get_config(self):
config = {
"num_tokens": self.num_tokens,
"output_mode": self.output_mode,
"sparse": self.sparse,
}
base_config = super().get_config()
return {**base_config, **config}
def call(self, inputs, count_weights=None):
if count_weights is not None:
if self.output_mode != "count":
raise ValueError(
"`count_weights` is not used when `output_mode` is not "
f"`'count'`. Received `count_weights={count_weights}`."
)
count_weights = self.backend.convert_to_tensor(
count_weights, dtype=self.compute_dtype
)
outputs = self._encode(inputs, count_weights)
return backend_utils.convert_tf_tensor(outputs)
View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/preprocessing/category_encoding.py:159 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/6d5965cce4e9406b.
Report an issue: GitHub.