tensorflow/models · error · ValueError

Number of filters: {conv_filters} is not divisible by size o

Error message

Number of filters: {conv_filters} is not divisible by size of the groups: {group_size}

What it means

Error "Number of filters: {conv_filters} is not divisible by size of the groups: {group_size}" thrown in tensorflow/models.

Source

Thrown at official/projects/edgetpu/vision/modeling/mobilenet_edgetpu_v2_model_blocks.py:699

                      strides: Any = (1, 1),
                      group_size: Optional[int] = None,
                      use_batch_norm: bool = True,
                      use_bias: bool = False,
                      activation: Any = None,
                      name: Optional[str] = None) -> tf_keras.layers.Layer:
  """2D group convolution with batchnorm and activation."""
  batch_norm = common_modules.get_batch_norm(config.batch_norm)
  bn_momentum = config.bn_momentum
  bn_epsilon = config.bn_epsilon
  data_format = tf_keras.backend.image_data_format()
  weight_decay = config.weight_decay
  if group_size is None:
    group_size = config.group_base_size

  name = name or ''
  # Compute the # of groups
  if conv_filters % group_size != 0:  # pyrefly: ignore[unsupported-operation]
    raise ValueError(f'Number of filters: {conv_filters} is not divisible by '
                     f'size of the groups: {group_size}')
  groups = int(conv_filters / group_size)  # pyrefly: ignore[unsupported-operation]
  # Collect args based on what kind of groupconv2d block is desired
  init_kwargs = {
      'kernel_size': kernel_size,
      'strides': strides,
      'use_bias': use_bias,
      'padding': 'same',
      'name': name + '_groupconv2d',
      'kernel_regularizer': tf_keras.regularizers.l2(weight_decay),
      'bias_regularizer': tf_keras.regularizers.l2(weight_decay),
      'filters': conv_filters,
      'groups': groups,
      'batch_norm_layer': batch_norm if use_batch_norm else None,
      'bn_epsilon': bn_epsilon,
      'bn_momentum': bn_momentum,
      'activation': activation,
      'data_format': data_format,

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/edgetpu/vision/modeling/mobilenet_edgetpu_v2_model_blocks.py:699 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/f061d2583265b705. Report an issue: GitHub.