tensorflow/models · error · ValueError

The block spec values {} do not match with the schema {}

Error message

The block spec values {} do not match with the schema {}

What it means

Error "The block spec values {} do not match with the schema {}" thrown in tensorflow/models.

Source

Thrown at official/vision/modeling/backbones/mobilenet.py:1188

    finegrain_classification_mode: If True, the model will keep the last layer
      large even for small multipliers, following
      https://arxiv.org/abs/1801.04381.

  Returns:
    A list of `BlockSpec` that defines structure of the base network.
  """

  spec_name = specs['spec_name']
  block_spec_schema = specs['block_spec_schema']
  block_specs = specs['block_specs']

  if not block_specs:
    raise ValueError(
        'The block spec cannot be empty for {} !'.format(spec_name))

  for block_spec in block_specs:
    if len(block_spec) != len(block_spec_schema):
      raise ValueError(
          'The block spec values {} do not match with the schema {}'.format(
              block_spec, block_spec_schema
          )
      )

  decoded_specs = []

  for s in block_specs:
    kw_s = dict(zip(block_spec_schema, s))
    decoded_specs.append(BlockSpec(**kw_s))

  # This adjustment applies to V2, V3, and V4
  if (spec_name != 'MobileNetV1'
      and finegrain_classification_mode
      and filter_size_scale < 1.0):
    decoded_specs[-1].filters /= filter_size_scale  # pytype: disable=annotation-type-mismatch

  for ds in decoded_specs:

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Make each block spec dict contain exactly the keys required by the schema shown in the error.
  2. Compare your custom block spec with the *_BLOCK_SPECS schema in mobilenet.py and fix the keys.

When it happens

Trigger: Thrown at official/vision/modeling/backbones/mobilenet.py:1188 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/e63a42e22bb4e6f5. Report an issue: GitHub.