{"record":{"id":"1b93b114024a8250","repo":"keras-team/keras","slug":"ragged-must-not-be-true-if-output-mode-is-in","errorCode":null,"errorMessage":"`ragged` must not be true if `output_mode` is `'int'`. Received: ragged={ragged} and output_mode={output_mode}","messagePattern":"`ragged` must not be true if `output_mode` is `'int'`\\. Received: ragged=(.+?) and output_mode=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/text_vectorization.py","lineNumber":319,"sourceCode":"        if output_mode == \"int\" and not (\n            isinstance(output_sequence_length, int)\n            or (output_sequence_length is None)\n        ):\n            raise ValueError(\n                \"`output_sequence_length` must be either None or an \"\n                \"integer when `output_mode` is 'int'. Received: \"\n                f\"output_sequence_length={output_sequence_length}\"\n            )\n\n        if output_mode != \"int\" and output_sequence_length is not None:\n            raise ValueError(\n                \"`output_sequence_length` must not be set if `output_mode` is \"\n                \"not 'int'. \"\n                f\"Received output_sequence_length={output_sequence_length}.\"\n            )\n\n        if ragged and output_mode != \"int\":\n            raise ValueError(\n                \"`ragged` must not be true if `output_mode` is \"\n                f\"`'int'`. Received: ragged={ragged} and \"\n                f\"output_mode={output_mode}\"\n            )\n\n        self._max_tokens = max_tokens\n        self._standardize = standardize\n        self._split = split\n        self._ngrams_arg = ngrams\n        if isinstance(ngrams, int):\n            self._ngrams = tuple(range(1, ngrams + 1))\n        else:\n            self._ngrams = ngrams\n        self._ragged = ragged\n\n        self._output_mode = output_mode\n        self._output_sequence_length = output_sequence_length\n        self._encoding = encoding","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/text_vectorization.py#L301-L337","documentation":"Constructor guard in TextVectorization.__init__: ragged=True was combined with output_mode='int'. Ragged output and integer-index mode are mutually exclusive because 'int' mode already returns variable-length (padded or ragged-like) sequences.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/text_vectorization.py:319 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use ragged=False with output_mode='int'","Keep ragged=True only with bag-of-words modes (one_hot, multi_hot, count, tf_idf)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}