tensorflow/models · error · ValueError

Requested downsampling at a non-existing starting depthwise.

Error message

Requested downsampling at a non-existing starting depthwise.

What it means

Raised in the UniversalInvertedBottleneckBlock __init__ when strides>1 is requested with start-dw downsampling enabled but no starting depthwise kernel size was given, so the starting depthwise conv does not exist to stride on.

Solutions

  1. Set the starting downsampling flag to False or add a starting depthwise conv.
  2. Use the correct block variant whose architecture includes a starting depthwise layer.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/vision/modeling/layers/nn_blocks.py:897 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/69e18ff1f6e742f7. Report an issue: GitHub.

Appendix: source

Thrown at official/vision/modeling/layers/nn_blocks.py:897

    self._use_residual = use_residual
    self._activation = activation
    self._depthwise_activation = depthwise_activation
    self._kernel_initializer = kernel_initializer
    self._use_layer_scale = use_layer_scale
    self._layer_scale_init_value = layer_scale_init_value
    self._norm_momentum = norm_momentum
    self._norm_epsilon = norm_epsilon
    self._kernel_regularizer = kernel_regularizer
    self._bias_regularizer = bias_regularizer
    self._output_intermediate_endpoints = output_intermediate_endpoints

    if strides > 1:
      if middle_dw_downsample and not middle_dw_kernel_size:
        raise ValueError(
            'Requested downsampling at a non-existing middle depthwise.'
        )
      if not middle_dw_downsample and not start_dw_kernel_size:
        raise ValueError(
            'Requested downsampling at a non-existing starting depthwise.'
        )

    if use_sync_bn:
      self._norm = tf_keras.layers.experimental.SyncBatchNormalization
    else:
      self._norm = tf_keras.layers.BatchNormalization
    if tf_keras.backend.image_data_format() == 'channels_last':
      self._bn_axis = -1
    else:
      self._bn_axis = 1
    if not depthwise_activation:
      self._depthwise_activation = activation
    if regularize_depthwise:
      self._depthsize_regularizer = kernel_regularizer
    else:
      self._depthsize_regularizer = None

View on GitHub (pinned to e006f5f0d5)