{"record":{"id":"2513ec0f6b85f99c","repo":"tensorflow/models","slug":"model-num-classes-must-be-2-when-not-for-all-class","errorCode":null,"errorMessage":"Model num_classes must be 2 when not for all classes.","messagePattern":"Model num_classes must be 2 when not for all classes\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/pointpillars/tasks/pointpillars.py","lineNumber":140,"sourceCode":"        ckpt_items.update(decoder=model.decoder)\n\n      ckpt = tf.train.Checkpoint(**ckpt_items)\n      status = ckpt.read(ckpt_dir_or_file)\n      status.expect_partial().assert_existing_objects_matched()\n\n    logging.info('Finished loading pretrained checkpoint from %s',\n                 ckpt_dir_or_file)\n\n  def build_inputs(\n      self,\n      params: cfg.DataConfig,\n      input_context: Optional[tf.distribute.InputContext] = None\n  ) -> tf.data.Dataset:\n    \"\"\"Build input dataset.\"\"\"\n    model_config = self.task_config.model\n    if (model_config.classes != 'all' and\n        model_config.num_classes != 2):\n      raise ValueError('Model num_classes must be 2 when not for all classes.')\n\n    decoder = decoders.ExampleDecoder(model_config.image, model_config.pillars)\n\n    image_size = [model_config.image.height, model_config.image.width]\n    anchor_sizes = [(a.length, a.width) for a in model_config.anchors]\n    anchor_labeler_config = model_config.anchor_labeler\n    parser = parsers.Parser(\n        classes=model_config.classes,\n        min_level=model_config.min_level,\n        max_level=model_config.max_level,\n        image_size=image_size,\n        anchor_sizes=anchor_sizes,\n        match_threshold=anchor_labeler_config.match_threshold,\n        unmatched_threshold=anchor_labeler_config.unmatched_threshold,\n        max_num_detections=model_config.detection_generator\n        .max_num_detections,\n        dtype=params.dtype,\n    )","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/pointpillars/tasks/pointpillars.py#L122-L158","documentation":"Error \"Model num_classes must be 2 when not for all classes.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/pointpillars/tasks/pointpillars.py:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}