tensorflow/models · error · KeyError

The key `{}` does not exist. To extend the existing keys, us

Error message

The key `{}` does not exist. To extend the existing keys, use `override` with `is_strict` = False.

What it means

Error "The key `{}` does not exist. To extend the existing keys, use `override` with `is_strict` = False." thrown in tensorflow/models.

Source

Thrown at official/modeling/hyperparams/params_dict.py:192

        False, keys in `override_params` can be different from what is currently
        defined in the ParamsDict. In this case, the ParamsDict will be extended
        to include the new keys.
    """
    if self._locked:
      raise ValueError('The ParamsDict has been locked. No change is allowed.')
    if isinstance(override_params, ParamsDict):
      override_params = override_params.as_dict()
    self._override(override_params, is_strict)  # pylint: disable=protected-access

  def _override(self, override_dict, is_strict=True):
    """The implementation of `override`."""
    for k, v in six.iteritems(override_dict):
      if k in ParamsDict.RESERVED_ATTR:
        raise KeyError('The key `%{}` is internally reserved. '
                       'Can not be overridden.')
      if k not in self.__dict__.keys():
        if is_strict:
          raise KeyError('The key `{}` does not exist. '
                         'To extend the existing keys, use '
                         '`override` with `is_strict` = False.'.format(k))
        else:
          logging.warning(
              'Adding new key `%s` to ParamsDict because is_strict=False.', k
          )
          self._set(k, v)
      else:
        if isinstance(v, dict):
          self.__dict__[k]._override(v, is_strict)  # pylint: disable=protected-access
        elif isinstance(v, ParamsDict):
          self.__dict__[k]._override(v.as_dict(), is_strict)  # pylint: disable=protected-access
        else:
          self.__dict__[k] = copy.deepcopy(v)

  def lock(self):
    """Makes the ParamsDict immutable."""
    self._locked = True

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/modeling/hyperparams/params_dict.py:192 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/131e9db7722617ea. Report an issue: GitHub.