tensorflow/models · error · ValueError

Block fn `{}` is not supported.

Error message

Block fn `{}` is not supported.

What it means

Error "Block fn `{}` is not supported." thrown in tensorflow/models.

Source

Thrown at official/vision/modeling/backbones/resnet.py:203

    self._bn_trainable = bn_trainable

    if tf_keras.backend.image_data_format() == 'channels_last':
      self._bn_axis = -1
    else:
      self._bn_axis = 1

    # Build ResNet.
    inputs = tf_keras.Input(shape=input_specs.shape[1:])
    x = self._stem(inputs)

    endpoints = {}
    for i, spec in enumerate(RESNET_SPECS[model_id]):
      if spec[0] == 'residual':
        block_fn = nn_blocks.ResidualBlock
      elif spec[0] == 'bottleneck':
        block_fn = nn_blocks.BottleneckBlock
      else:
        raise ValueError('Block fn `{}` is not supported.'.format(spec[0]))
      x = self._block_group(
          inputs=x,
          filters=int(spec[1] * self._depth_multiplier),
          strides=(1 if i == 0 else 2),
          block_fn=block_fn,
          block_repeats=spec[2],
          stochastic_depth_drop_rate=nn_layers.get_stochastic_depth_rate(
              self._init_stochastic_depth_rate, i + 2, 5),
          name='block_group_l{}'.format(i + 2))
      endpoints[str(i + 2)] = x

    self._output_specs = {l: endpoints[l].get_shape() for l in endpoints}

    super(ResNet, self).__init__(inputs=inputs, outputs=endpoints, **kwargs)

  def _stem(self, inputs):
    stem_depth_multiplier = self._depth_multiplier if self._scale_stem else 1.0
    if self._stem_type == 'v0':

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Use a supported ResNet block_fn: 'bottleneck' or 'basic'.
  2. Check the block_fn value in the ResNet backbone config for typos.

When it happens

Trigger: Thrown at official/vision/modeling/backbones/resnet.py:203 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/5083519069fe0dee. Report an issue: GitHub.