tensorflow/models · error · ValueError

Unexpected inputs type to %s.

Error message

Unexpected inputs type to %s.

What it means

Error "Unexpected inputs type to %s." thrown in tensorflow/models.

Source

Thrown at official/projects/pixel/modeling/pixel.py:115

    return self.token_cls(patch_embeds)

  def call(self, inputs):  # pylint:disable=signature-mismatch
    if isinstance(inputs, dict):
      images = inputs.get('pixel_values', None)
      attention_mask = inputs.get('attention_mask', None)
      attention_mask = tf.transpose(
          tf.concat(
              values=[
                  tf.ones((1, tf.shape(attention_mask)[0]), tf.float32),
                  tf.transpose(attention_mask),
              ],
              axis=0,
          )
      )
      attention_mask = tf.einsum('ij,ik->ijk', attention_mask, attention_mask)
      attention_mask = tf.cast(attention_mask, tf.int32)
    else:
      raise ValueError('Unexpected inputs type to %s.' % self.__class__)

    images = tf.transpose(images, perm=[0, 2, 3, 1])
    patch_embeds = self.to_embed(images)
    patch_shape = tf.shape(patch_embeds)
    patch_embeds = tf.reshape(
        patch_embeds, (patch_shape[0], -1, patch_shape[-1])
    )
    patch_embeds = self.insert_cls(patch_embeds)

    return self.encoder((patch_embeds, attention_mask))


class PixelClassifier(tf_keras.layers.Layer):
  """Pixel classifier for finetuning. Uses the cls token."""

  def __init__(self, encoder, num_classes, **kwargs):
    super().__init__(**kwargs)
    self.encoder = encoder

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/pixel/modeling/pixel.py:115 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/d06b499bc1011383. Report an issue: GitHub.