tensorflow/models · error · ValueError

`inputs` must have two elements.

Error message

`inputs` must have two elements.

What it means

Error "`inputs` must have two elements." thrown in tensorflow/models.

Source

Thrown at official/projects/perceiver/modeling/layers/decoder.py:127

      inputs:
        Expect inputs to be a tuple of perceiver's decoder query tensor and
        latent tensor (z). For the cross attention block, `z` is the key-value
        tensor and decoder query is the query tensor.
        Latent tensor comes from the self-attention processing blocks and
        decoder query comes from users to query for the desired output.
      training:
        Flag to indicate training status.
      query_mask:
        mask used to create the attention mask for the query tensor in the
        cross attention block.

    Returns:
      `tf.Tensor` decoded output of latent vector via the query.
    """
    if not isinstance(inputs, collections.abc.Sequence):
      raise ValueError("`inputs` must be a sequence.")
    if len(inputs) != 2:
      raise ValueError("`inputs` must have two elements.")

    query, z = inputs
    # Cross-attention decoding.
    # key, value: B x N x K; query: B x M x K
    # Attention maps -> B x N x M
    # Output -> B x M x K
    # Construct cross attention and linear layer lazily, in case we don't need
    # them.
    if query_mask is None:
      attention_mask = None
    else:
      attention_mask = utils.make_cross_attention_mask(
          query_mask=query_mask,
          kv_mask=tf.ones(tf.shape(z)[:2], dtype=tf.int32))

    output = self._decoding_cross_attn(
        (query, z, attention_mask),
        training=training)

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/perceiver/modeling/layers/decoder.py:127 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/c8897525635b81be. Report an issue: GitHub.