tensorflow/models · error · ValueError
Unexpected inputs to %s with length at %d
Error message
Unexpected inputs to %s with length at %d
What it means
Error "Unexpected inputs to %s with length at %d" thrown in tensorflow/models.
Source
Thrown at official/vision/modeling/layers/nn_blocks.py:2644
'stochastic_depth_drop_rate': self._stochastic_depth_drop_rate,
'layer_scale_init_value': self._layer_scale_init_value,
'transformer_partition_dims': self._transformer_partition_dims,
'max_attention_inference_parallelism': (
self._max_attention_inference_parallelism
),
})
return config
def call(self, inputs, output_range=None, training=None):
"""Transformer self-attention encoder block call."""
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)))
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, :]
input_tensor = self._attention_layer_norm(input_tensor)
if key_value is not None:
key_value = self._attention_layer_norm(key_value)
target_tensor = input_tensor[:, 0:output_range, :]
if attention_mask is not None:
attention_mask = attention_mask[:, 0:output_range, :]
else:
if self._norm_first:
source_tensor = input_tensorView on GitHub (pinned to e006f5f0d5)
Solutions
- Pass the expected number of input tensors to the block as shown in the error.
- Check the block's call signature and supply exactly the required inputs.
When it happens
Trigger: Thrown at official/vision/modeling/layers/nn_blocks.py:2644 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/25295361f06a8aea.
Report an issue: GitHub.