tensorflow/models · error · ValueError

Only support MosaicDecoderHead for head.

Error message

Only support MosaicDecoderHead for head.

What it means

Error "Only support MosaicDecoderHead for head." thrown in tensorflow/models.

Source

Thrown at official/projects/mosaic/qat/modeling/factory.py:65

    ckpt = tf.train.Checkpoint(model=model, **model.checkpoint_items)
    status = ckpt.read(original_checkpoint)
    status.expect_partial().assert_existing_objects_matched()

  scope_dict = {
      'L2': tf_keras.regularizers.l2,
  }

  model.use_legacy_config = True  # Ensures old Keras serialization format
  # Apply QAT to backbone (a tf_keras.Model) first, and then neck and head.
  with tfmot.quantization.keras.quantize_scope(scope_dict):
    annotated_backbone = tfmot.quantization.keras.quantize_annotate_model(
        model.backbone)
    optimized_backbone = tfmot.quantization.keras.quantize_apply(
        annotated_backbone, scheme=schemes.Default8BitQuantizeScheme())

    # Check for valid encoder and head.
    if not isinstance(model.head, mosaic_head.MosaicDecoderHead):
      raise ValueError('Only support MosaicDecoderHead for head.')
    if not isinstance(model.neck, mosaic_blocks.MosaicEncoderBlock):
      raise ValueError('Only support MosaicEncoderBlock for encoder.')

    head = qat_mosaic_head.MosaicDecoderHeadQuantized.from_config(
        model.head.get_config())
    neck = qat_nn_blocks.MosaicEncoderBlockQuantized.from_config(
        model.neck.get_config())

    mask_scoring_head = None
    if model.mask_scoring_head is not None:
      mask_scoring_head = qat_nn_layers.MaskScoringQuantized.from_config(
          model.mask_scoring_head.get_config()
      )

  optimized_model = mosaic_model.MosaicSegmentationModel(
      backbone=optimized_backbone,
      head=head,
      neck=neck,

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/mosaic/qat/modeling/factory.py:65 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/a568321fa09eb5fc. Report an issue: GitHub.