tensorflow/models · error · ValueError

The argument `kernel_size` cannot contain 0(s). Received: %s

Error message

The argument `kernel_size` cannot contain 0(s). Received: %s

What it means

Error "The argument `kernel_size` cannot contain 0(s). Received: %s" thrown in tensorflow/models.

Source

Thrown at official/vision/modeling/layers/nn_layers.py:890

    if use_buffered_input:
      padding[time_axis] = [0, 0]
    else:
      padding[time_axis] = [padding[time_axis][0] + padding[time_axis][1], 0]
    return padding

  def _causal_validate_init(self):
    """Validates the Conv layer initial configuration."""
    # Overriding this method is meant to circumvent unnecessary errors when
    # using causal padding.
    if (self.filters is not None
        and self.filters % self.groups != 0):
      raise ValueError(
          'The number of filters must be evenly divisible by the number of '
          'groups. Received: groups={}, filters={}'.format(
              self.groups, self.filters))

    if not all(self.kernel_size):
      raise ValueError('The argument `kernel_size` cannot contain 0(s). '
                       'Received: %s' % (self.kernel_size,))

  def _buffered_spatial_output_shape(self, spatial_output_shape: List[int]):
    """Computes the spatial output shape from the input shape."""
    # When buffer padding, use 'valid' padding across time. The output shape
    # across time should be the input shape minus any padding, assuming
    # the stride across time is 1.
    if self._use_buffered_input and spatial_output_shape[0] is not None:
      padding = self._compute_buffered_causal_padding(
          tf.zeros([1] + spatial_output_shape + [1]), use_buffered_input=False)
      spatial_output_shape[0] -= sum(padding[1])
    return spatial_output_shape


@tf_keras.utils.register_keras_serializable(package='Vision')
class Conv2D(tf_keras.layers.Conv2D, CausalConvMixin):
  """Conv2D layer supporting CausalConv.

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Set kernel_size to positive integers only; remove any 0 entries.
  2. Check the kernel_size config value for a stray 0.

When it happens

Trigger: Thrown at official/vision/modeling/layers/nn_layers.py:890 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/9f88775e4a03e25c. Report an issue: GitHub.