tensorflow/models · error · ValueError
Unexpected inputs type to
Error message
Unexpected inputs type to %s.
What it means
Type guard in the PIXEL model's call: inputs must be a dict containing 'pixel_values' (and optionally 'attention_mask'); if inputs is neither a dict nor a tensor of the expected kind, the method cannot extract images and raises this ValueError naming the layer.
Solutions
- Pass a dict with 'pixel_values' as produced by the PIXEL processor
- Check that the previous pipeline stage does not return a list or tuple instead of a dict
- Inspect type(inputs) at the call site to confirm what is actually forwarded
Defensive patterns
Strategy: type-guard
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.
Appendix: 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 = encoderView on GitHub (pinned to e006f5f0d5)