tensorflow/models · error · ValueError
Only support MosaicEncoderBlock for encoder.
Error message
Only support MosaicEncoderBlock for encoder.
What it means
Error "Only support MosaicEncoderBlock for encoder." thrown in tensorflow/models.
Source
Thrown at official/projects/mosaic/qat/modeling/factory.py:67
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,
mask_scoring_head=mask_scoring_head,
)View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/mosaic/qat/modeling/factory.py:67 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/ed17d1a2fd9b5413.
Report an issue: GitHub.