{"record":{"id":"7cd62054251f2971","repo":"keras-team/keras","slug":"output-sequence-length-must-not-be-set-if-outpu","errorCode":null,"errorMessage":"`output_sequence_length` must not be set if `output_mode` is not 'int'. Received output_sequence_length={output_sequence_length}.","messagePattern":"`output_sequence_length` must not be set if `output_mode` is not 'int'\\. Received output_sequence_length=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/text_vectorization.py","lineNumber":312,"sourceCode":"            raise ValueError(\n                \"`ngrams` must be None, an integer, or a tuple of \"\n                f\"integers. Received: ngrams={ngrams}\"\n            )\n\n        # 'output_sequence_length' must be one of (None, int) and is only\n        # set if output_mode is \"int\"\".\n        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))","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/text_vectorization.py#L294-L330","documentation":"Constructor guard in TextVectorization.__init__: output_sequence_length was set (not None) while output_mode is not 'int'. Sequence padding only exists for integer-index output; bag-of-words modes (one_hot, multi_hot, count, tf_idf) produce fixed-size vectors where the argument is meaningless, so it is rejected.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/text_vectorization.py:312 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set output_sequence_length=None when using output_mode in {'one_hot', 'multi_hot', 'count', 'tf_idf'}","Only pass output_sequence_length together with output_mode='int'"],"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"}