tensorflow/models · error · ValueError

Feature map sizes {(h, w)} not divisible by window size ({wi

Error message

Feature map sizes {(h, w)} not divisible by window size ({window_size}).

What it means

Error "Feature map sizes {(h, w)} not divisible by window size ({window_size})." thrown in tensorflow/models.

Source

Thrown at official/projects/maxvit/modeling/maxvit.py:277

    Note that unsuitable feature or window sizes may be costly on TPU due to
    padding sizes:
    https://docs.google.com/document/d/1GojE1Q7hR2qyi0mIfnTHgERfl7Dmsj6xPQ31MQo3xUk/edit#

    Args:
      features: [B, H, W, C] feature maps.

    Returns:
      Partitioned features: [B, nH, nW, wSize, wSize, c].

    Raises:
      ValueError: If the feature map sizes are not divisible by window sizes.
    """

    _, h, w, c = features.shape
    window_size = self._window_size

    if h % window_size != 0 or w % window_size != 0:
      raise ValueError(
          f'Feature map sizes {(h, w)} '
          f'not divisible by window size ({window_size}).'
      )

    features = tf.reshape(
        features,
        (-1, h // window_size, window_size, w // window_size, window_size, c),
    )
    features = tf.transpose(features, (0, 1, 3, 2, 4, 5))
    features = tf.reshape(features, (-1, window_size, window_size, c))
    return features

  def window_stitch_back(
      self, features: tf.Tensor, window_size: int, h: int, w: int
  ) -> tf.Tensor:
    """Reverse window_partition."""
    features = tf.reshape(
        features,

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/maxvit/modeling/maxvit.py:277 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/6e993737659eb075. Report an issue: GitHub.