tensorflow/models · error · ValueError

unrecognized pooler type: {pooler}

Error message

unrecognized pooler type: {pooler}

What it means

Error "unrecognized pooler type: {pooler}" thrown in tensorflow/models.

Source

Thrown at official/vision/modeling/backbones/vit.py:318

    endpoints = {}
    if output_attention_scores:
      x, attention_scores = encoder_output
      endpoints['attention_scores'] = attention_scores
    else:
      x = encoder_output

    if pooler == 'token':
      output_feature = x[:, 1:]
      x = x[:, 0]
    elif pooler == 'gap':
      output_feature = x
      x = tf.reduce_mean(x, axis=1)
    elif pooler == 'none':
      output_feature = x
      x = tf.identity(x, name='encoded_tokens')
    else:
      raise ValueError(f'unrecognized pooler type: {pooler}')

    if output_2d_feature_maps:
      # Use the closest feature level.
      feat_level = round(math.log2(patch_size))
      logging.info(
          'VisionTransformer patch size %d and feature level: %d',
          patch_size,
          feat_level,
      )
      endpoints[str(feat_level)] = tf.reshape(
          output_feature, [-1, feat_h, feat_w, x.shape.as_list()[-1]])

      # Don"t include `pre_logits` or `encoded_tokens` to support decoders.
      self._output_specs = {k: v.shape for k, v in endpoints.items()}

    if representation_size:
      x = layers.Dense(
          representation_size,

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Set pooler to 'token' or 'gap' in the ViT backbone config.
  2. Check the pooler value for typos.

When it happens

Trigger: Thrown at official/vision/modeling/backbones/vit.py:318 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/023036f323a58dd8. Report an issue: GitHub.