tensorflow/models · error · ValueError

/ of Bottleneck weights is transformed.

Error message

{}/{} of Bottleneck weights is transformed.

What it means

Integrity check in the vision n-bit transform's replacement: quantized layer weights are zipped against the original layer's names_and_weights; if the quantized class yields more non-QAT weights than the original layer has, the index runs past the source list and this error reports the mapping counts.

Solutions

  1. Verify the quantized layer class exposes the same non-QAT weights as the original
  2. Fix _is_quantization_weight_name to recognize all QAT-injected weights
  3. Keep the original and quantized layer definitions in sync
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at official/projects/qat/vision/n_bit/schemes.py:94 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/5e1692d9c3eeed97. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/qat/vision/n_bit/schemes.py:94

    bottleneck_config['num_bits_activation'] = self._num_bits_activation
    bottleneck_names_and_weights = list(match_layer.names_and_weights)
    quantized_layer = self._quantized_layer_class(
        **bottleneck_config)
    dummy_input_shape = [1, 1, 1, 1]
    quantized_layer.compute_output_shape(dummy_input_shape)
    quantized_names_and_weights = zip(
        [weight.name for weight in quantized_layer.weights],
        quantized_layer.get_weights())
    match_idx = 0
    names_and_weights = []
    for name_and_weight in quantized_names_and_weights:
      if not self._is_quantization_weight_name(name=name_and_weight[0]):
        name_and_weight = bottleneck_names_and_weights[match_idx]
        match_idx = match_idx + 1
      names_and_weights.append(name_and_weight)

    if match_idx != len(bottleneck_names_and_weights):
      raise ValueError('{}/{} of Bottleneck weights is transformed.'.format(
          match_idx, len(bottleneck_names_and_weights)))
    quantized_layer_config = keras.layers.serialize(quantized_layer)
    quantized_layer_config['name'] = quantized_layer_config['config']['name']
    layer_metadata = {
        'quantize_config':
            configs.DefaultNBitOutputQuantizeConfig(
                num_bits_weight=self._num_bits_weight,
                num_bits_activation=self._num_bits_activation)}

    return _LayerNode(
        quantized_layer_config,
        metadata=layer_metadata,
        names_and_weights=names_and_weights)


class QuantizeLayoutTransform(
    tfmot.quantization.keras.QuantizeLayoutTransform):
  """Default model transformations."""

View on GitHub (pinned to e006f5f0d5)