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/Deploy/pet_grading_cloud_deployment/pet_grade_classifier.py:97

      num_classes: int,
      pooling: str = POOLING_CLS,
  ):
    """Initializes the Dinov3Classification model.

    Args:
        dinov3_repo_dir: Path to the cloned DINOv3 repository.
        model_name: Name of the DINOv3 backbone variant to load.
        num_classes: The number of output classes for the classification head.
        pooling: The pooling strategy to use ('cls' or 'cls_mean_patch').
          Defaults to 'cls'.

    Raises:
        ValueError: If an unsupported pooling strategy is provided.
    """
    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 = _load_backbone(
        dinov3_repo_dir=dinov3_repo_dir,
        model_name=model_name,
    )

    backbone_hidden_size = self.backbone_model.norm.normalized_shape[0]
    head_input_features = (
        backbone_hidden_size
        if pooling == POOLING_CLS
        else 2 * backbone_hidden_size
    )
    self.head = nn.Linear(
        in_features=head_input_features,

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/waste_identification_ml/Deploy/pet_grading_cloud_deployment/pet_grade_classifier.py:97 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/a7a8d5195ae357ad. Report an issue: GitHub.