tensorflow/models · error · ValueError
Unexpected inputs to {self.__class__} with length at {len(in
Error message
Unexpected inputs to {self.__class__} with length at {len(inputs)}. What it means
Error "Unexpected inputs to {self.__class__} with length at {len(inputs)}." thrown in tensorflow/models.
Source
Thrown at official/nlp/modeling/layers/pack_optimization.py:157
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self._output_range is not None:
raise ValueError(f'{self.__class__} does not '
'support `output_range` argument.')
# TODO(b/337888023): Support block sparse attention with strided inputs.
if self._src_block_size is not None:
raise ValueError(f'{self.__class__} does not '
'support block sparse attention.')
def call(self, inputs, stride: tf.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(f'Unexpected inputs to {self.__class__} with '
f'length at {len(inputs)}.')
else:
input_tensor, key_value, attention_mask = (inputs, None, None)
target_tensor = input_tensor[:, ::stride, :]
if attention_mask is not None:
attention_mask = attention_mask[:, ::stride, :]
if key_value is None:
key_value = input_tensor
attention_output = self._attention_layer(
query=target_tensor, value=key_value, attention_mask=attention_mask)
attention_output = self._attention_dropout(attention_output)
attention_output = target_tensor + self._rezero_a * attention_output
if self._use_layer_norm:
attention_output = self._attention_layer_norm(attention_output)
else:View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/nlp/modeling/layers/pack_optimization.py:157 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/6a0b5c7c4ac1bf9a.
Report an issue: GitHub.