{"record":{"id":"e80199c95352522d","repo":"keras-team/keras","slug":"unrecognized-keyword-argument-s-kwargs","errorCode":null,"errorMessage":"Unrecognized keyword argument(s): {kwargs}","messagePattern":"Unrecognized keyword argument\\(s\\): (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/index_lookup.py","lineNumber":251,"sourceCode":"\n        # Remember original `vocabulary` as `input_vocabulary` for serialization\n        # via `get_config`. However, if `vocabulary` is a file path or a URL, we\n        # serialize the vocabulary as an asset and clear the original path/URL.\n        self.input_vocabulary = (\n            vocabulary if not isinstance(vocabulary, str) else None\n        )\n        self.input_idf_weights = idf_weights\n\n        # We set this hidden attr to\n        # persist the fact that we have have a non-adaptable layer with a\n        # manually set vocab.\n        self._has_input_vocabulary = kwargs.pop(\n            \"has_input_vocabulary\", (vocabulary is not None)\n        )\n        kwargs.pop(\"trainable\", None)\n        kwargs.pop(\"dtype\", None)\n        if kwargs:\n            raise ValueError(f\"Unrecognized keyword argument(s): {kwargs}\")\n\n        if invert:\n            self._key_dtype = \"int64\"\n            self._value_dtype = self.vocabulary_dtype\n            mask_key = 0\n            mask_value = mask_token\n            self._default_value = self.oov_token\n        else:\n            self._key_dtype = self.vocabulary_dtype\n            self._value_dtype = \"int64\"\n            mask_key = mask_token\n            # Masks should map to 0 for int output and be dropped otherwise. Max\n            # ints will be dropped from the bincount op.\n            mask_value = (\n                0\n                if self.output_mode == \"int\"\n                else tf.as_dtype(self._value_dtype).max\n            )","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/index_lookup.py#L233-L269","documentation":"IndexLookup.__init__ pops a few legacy kwargs (has_input_vocabulary, trainable, dtype) and rejects anything else left over. This surfaces typos and arguments that were renamed or removed across Keras versions.","triggerScenarios":"Passing a kwarg not in the signature, e.g. `IndexLookup(vocabulary_size=5000)` or a misspelled `max_token`; forwarding a config dict with `**cfg` built for a different layer version.","commonSituations":"Migrating configs from tf.keras TextVectorization or older Keras releases whose signatures differed; generic kwargs-forwarding from experiment frameworks.","solutions":["Remove or correct the unknown keyword; current args include max_tokens, num_oov_indices, oov_token, mask_token, vocabulary_dtype, idf_weights, invert, output_mode, sparse, pad_to_max_tokens, vocabulary, name.","Check the real signature for your version: `inspect.signature(IndexLookup.__init__)`.","Validate config dicts against the signature before forwarding them with `**cfg`."],"exampleFix":"# before\nlayer = IndexLookup(max_token=20000)\n\n# after\nlayer = IndexLookup(max_tokens=20000)","handlingStrategy":"type-guard","validationCode":"import inspect\nsig = inspect.signature(IndexLookup.__init__)\nknown = set(sig.parameters) - {'self', 'kwargs'}\nunknown = set(cfg) - known\nif unknown:\n    raise ValueError('Unknown IndexLookup args: %s' % unknown)\nlayer = IndexLookup(**cfg)","typeGuard":"def valid_lookup_kwargs(cfg) -> bool:\n    import inspect\n    params = set(inspect.signature(IndexLookup.__init__).parameters)\n    return not (set(cfg) - params - {'self'})","tryCatchPattern":"try:\n    layer = IndexLookup(**cfg)\nexcept ValueError as e:\n    if 'Unrecognized keyword' in str(e):\n        cfg = {k: v for k, v in cfg.items() if k in KNOWN_ARGS}\n        layer = IndexLookup(**cfg)\n    else:\n        raise","preventionTips":["Validate config dicts against inspect.signature before star-forwarding them.","Pin the Keras version and read that version's layer docs when migrating configs."],"tags":["keras","preprocessing","index-lookup","api-mismatch","typo"],"backgroundTag":"invalid-keyword-argument","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}