{"record":{"id":"7ffc5af2f9c32cc4","repo":"keras-team/keras","slug":"the-value-of-num-oov-indices-argument-for-integ","errorCode":null,"errorMessage":"The value of `num_oov_indices` argument for `IntegerLookup` must >= 0. Received: num_oov_indices={num_oov_indices}","messagePattern":"The value of `num_oov_indices` argument for `IntegerLookup` must >= 0\\. Received: num_oov_indices=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/integer_lookup.py","lineNumber":364,"sourceCode":"        sparse=False,\n        pad_to_max_tokens=False,\n        oov_method=\"floormod\",\n        salt=None,\n        name=None,\n        **kwargs,\n    ):\n        if not tf.available:\n            raise ImportError(\n                \"Layer IntegerLookup requires TensorFlow. \"\n                \"Install it via `pip install tensorflow`.\"\n            )\n        if max_tokens is not None and max_tokens <= 1:\n            raise ValueError(\n                \"If `max_tokens` is set for `IntegerLookup`, it must be \"\n                f\"greater than 1. Received: max_tokens={max_tokens}\"\n            )\n        if num_oov_indices < 0:\n            raise ValueError(\n                \"The value of `num_oov_indices` argument for `IntegerLookup` \"\n                \"must >= 0. Received: num_oov_indices=\"\n                f\"{num_oov_indices}\"\n            )\n        if sparse and backend.backend() != \"tensorflow\":\n            raise ValueError(\n                \"`sparse=True` can only be used with the TensorFlow backend.\"\n            )\n        if vocabulary_dtype != \"int64\":\n            raise ValueError(\n                \"Only `vocabulary_dtype='int64'` is supported \"\n                \"at this time. Received: \"\n                f\"vocabulary_dtype={vocabulary_dtype}\"\n            )\n        super().__init__(\n            max_tokens=max_tokens,\n            num_oov_indices=num_oov_indices,\n            mask_token=mask_token,","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/integer_lookup.py#L346-L382","documentation":"num_oov_indices for IntegerLookup must be a non-negative integer; negative values are rejected in __init__ because a negative count of out-of-vocabulary buckets is meaningless.","triggerScenarios":"Passing num_oov_indices=-1 (or any negative) to keras.layers.IntegerLookup(); configs generated from arithmetic that underflows, e.g. num_oov_indices = vocab_size - something.","commonSituations":"Copying StringLookup configs where a sentinel was used; programmatic generation of layer params with buggy math.","solutions":["Set num_oov_indices to 0 or a positive integer (1 is the common default)","Clamp computed values: max(0, n)","Use 0 only if inputs are guaranteed to contain solely known integers"],"exampleFix":"// before\nlayer = IntegerLookup(num_oov_indices=-1)\n// after\nlayer = IntegerLookup(num_oov_indices=1)","handlingStrategy":"validation","validationCode":"assert isinstance(num_oov_indices, int) and num_oov_indices >= 0","typeGuard":"def valid_oov(n): return isinstance(n, int) and n >= 0","tryCatchPattern":null,"preventionTips":["Validate layer configs against a schema before construction","Default to 1 OOV bucket"],"tags":["keras","argument-validation","integer-lookup"],"backgroundTag":"invalid-argument-value","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}