tensorflow/models · error · ValueError

Missing required key `input_tensor` in input dictionary.

Error message

Missing required key `input_tensor` in input dictionary.

What it means

Error "Missing required key `input_tensor` in input dictionary." thrown in tensorflow/models.

Source

Thrown at official/nlp/modeling/layers/transformer_encoder_block.py:618

      if len(inputs) == 2:
        input_tensor, attention_mask = inputs
        key_value = None
      elif len(inputs) == 3:
        input_tensor, key_value, attention_mask = inputs
      else:
        raise ValueError("Unexpected inputs to %s with length at %d" %
                         (self.__class__, len(inputs)))
    elif isinstance(inputs, dict):
      if not set(inputs.keys()).issubset(
          set(["input_tensor", "key_value_tensor", "attention_mask"])
      ):
        raise ValueError(
            f"Unexpected keys in input dictionary to: {inputs.keys()}"
        )
      try:
        input_tensor = inputs["input_tensor"]
      except KeyError as e:
        raise ValueError(
            "Missing required key `input_tensor` in input dictionary."
        ) from e
      key_value = inputs.get("key_value_tensor", None)
      attention_mask = inputs.get("attention_mask", None)
    else:
      input_tensor, key_value, attention_mask = (inputs, None, None)

    if output_range is None:
      output_range = self._output_range
    if output_range:
      if self._norm_first:
        source_tensor = input_tensor[:, 0:output_range, :]
        if self._use_query_residual:
          # `source_tensor` is only used for the residual connection.
          source_tensor = self._apply_lowrank_query_projection(
              source_tensor, attention_mask
          )

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/nlp/modeling/layers/transformer_encoder_block.py:618 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/6c380c0a60d41bfe. Report an issue: GitHub.