tensorflow/models · error · ValueError

Unsupported pooling strategy: {pooling!r}. Expected one of {

Error message

Unsupported pooling strategy: {pooling!r}. Expected one of {SUPPORTED_POOLING_STRATEGIES}.

What it means

Error "Unsupported pooling strategy: {pooling!r}. Expected one of {SUPPORTED_POOLING_STRATEGIES}." thrown in tensorflow/models.

Source

Thrown at official/projects/waste_identification_ml/fine_tuning/Dinov3_image_classifier/models.py:154

    """Initializes the DINOv3 classifier with an already-loaded backbone.

    Args:
      backbone_model: The pre-loaded DINOv3 backbone module (`nn.Module`). Note
        that if `fine_tune=False`, the parameters of `backbone_model` are
        modified in-place (`requires_grad=False`).
      number_of_classes: Number of output classes.
      pooling: Feature extraction strategy. One of
        `SUPPORTED_POOLING_STRATEGIES`.
      fine_tune: If True, backbone parameters remain trainable. If False, they
        are frozen.

    Raises:
      ValueError: If `pooling` is not a supported strategy.
    """
    super().__init__()

    if pooling not in SUPPORTED_POOLING_STRATEGIES:
      raise ValueError(
          f"Unsupported pooling strategy: {pooling!r}. "
          f"Expected one of {SUPPORTED_POOLING_STRATEGIES}."
      )

    self.pooling = pooling
    self.backbone_model = backbone_model

    backbone_hidden_size = self.backbone_model.norm.normalized_shape[0]
    if pooling == POOLING_CLS:
      head_input_features = backbone_hidden_size
    else:
      # 'cls_mean_patch' concatenates two vectors of size
      # backbone_hidden_size.
      head_input_features = 2 * backbone_hidden_size

    self.head = nn.Linear(
        in_features=head_input_features,
        out_features=number_of_classes,

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/waste_identification_ml/fine_tuning/Dinov3_image_classifier/models.py:154 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/8f588139aa3b8b5b. Report an issue: GitHub.