tensorflow/models · error · ValueError
Unexpected keys in input dictionary to: {inputs.keys()}
Error message
Unexpected keys in input dictionary to: {inputs.keys()} What it means
Error "Unexpected keys in input dictionary to: {inputs.keys()}" thrown in tensorflow/models.
Source
Thrown at official/nlp/modeling/layers/transformer_encoder_block.py:612
set the `output_range` for serving.
Returns:
An output tensor with the same dimensions as input/query tensor.
"""
if isinstance(inputs, (list, tuple)):
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, :]View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/nlp/modeling/layers/transformer_encoder_block.py:612 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/616e98607ef9ed15.
Report an issue: GitHub.