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/projects/lra/linformer_encoder_block.py:378

        additional attention mask. [`query tensor`, `key value tensor`,
        `attention mask`] to have separate input streams for the query, and
        key/value to the multi-head attention.
      output_range: the sequence output range, [0, output_range) for slicing the
        target sequence. `None` means the target sequence is not sliced. If you
        would like to have no change to the model training, it is better to only
        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))
        )
    else:
      input_tensor, key_value, attention_mask = (inputs, None, None)

    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_kv(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_tensor

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/lra/linformer_encoder_block.py:378 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/0bbac0f8105e2fbd. Report an issue: GitHub.