{"record":{"id":"6d5965cce4e9406b","repo":"keras-team/keras","slug":"count-weights-is-not-used-when-output-mode-is","errorCode":null,"errorMessage":"`count_weights` is not used when `output_mode` is not `'count'`. Received `count_weights={count_weights}`.","messagePattern":"`count_weights` is not used when `output_mode` is not `'count'`\\. Received `count_weights=(.+?)`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/category_encoding.py","lineNumber":159,"sourceCode":"    def compute_output_spec(self, inputs, count_weights=None):\n        output_shape = self.compute_output_shape(inputs.shape)\n        return KerasTensor(\n            output_shape, dtype=self.compute_dtype, sparse=self.sparse\n        )\n\n    def get_config(self):\n        config = {\n            \"num_tokens\": self.num_tokens,\n            \"output_mode\": self.output_mode,\n            \"sparse\": self.sparse,\n        }\n        base_config = super().get_config()\n        return {**base_config, **config}\n\n    def call(self, inputs, count_weights=None):\n        if count_weights is not None:\n            if self.output_mode != \"count\":\n                raise ValueError(\n                    \"`count_weights` is not used when `output_mode` is not \"\n                    f\"`'count'`. Received `count_weights={count_weights}`.\"\n                )\n            count_weights = self.backend.convert_to_tensor(\n                count_weights, dtype=self.compute_dtype\n            )\n        outputs = self._encode(inputs, count_weights)\n        return backend_utils.convert_tf_tensor(outputs)\n","sourceCodeStart":141,"sourceCodeEnd":168,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/category_encoding.py#L141-L168","documentation":"Error \"`count_weights` is not used when `output_mode` is not `'count'`. Received `count_weights={count_weights}`.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/category_encoding.py:159 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"}