{"record":{"id":"2346221dd8009a9d","repo":"tensorflow/models","slug":"distill-ground-truth-ratio-has-to-be-within-0-1","errorCode":null,"errorMessage":"distill_ground_truth_ratio has to be within [0, 1].","messagePattern":"distill_ground_truth_ratio has to be within \\[0, 1\\]\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/mobilebert/distillation.py","lineNumber":164,"sourceCode":"    transfer_teacher_layers = layer_wise_config.transfer_teacher_layers\n    num_teacher_layers = (\n        self._task_config.teacher_model.encoder.mobilebert.num_blocks)\n    num_student_layers = (\n        self._task_config.student_model.encoder.mobilebert.num_blocks)\n    if transfer_teacher_layers and len(\n        transfer_teacher_layers) != num_student_layers:\n      raise ValueError('The number of `transfer_teacher_layers` %s does not '\n                       'match the number of student layers. %d' %\n                       (transfer_teacher_layers, num_student_layers))\n    if not transfer_teacher_layers and (num_teacher_layers !=\n                                        num_student_layers):\n      raise ValueError('`transfer_teacher_layers` is not specified, and the '\n                       'number of teacher layers does not match '\n                       'the number of student layers.')\n\n    ratio = progressive.pretrain_distill_config.distill_ground_truth_ratio\n    if ratio < 0 or ratio > 1:\n      raise ValueError('distill_ground_truth_ratio has to be within [0, 1].')\n\n    # A non-trainable layer for feature normalization for transfer loss\n    self._layer_norm = tf_keras.layers.LayerNormalization(\n        axis=-1,\n        beta_initializer='zeros',\n        gamma_initializer='ones',\n        trainable=False)\n\n    # Build the teacher and student pretrainer model.\n    self._teacher_pretrainer = self._build_pretrainer(\n        self._task_config.teacher_model, name='teacher')\n    self._student_pretrainer = self._build_pretrainer(\n        self._task_config.student_model, name='student')\n\n    base_task.Task.__init__(\n        self, params=task_config, logging_dir=logging_dir)\n    policies.ProgressivePolicy.__init__(self)\n","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/mobilebert/distillation.py#L146-L182","documentation":"Error \"distill_ground_truth_ratio has to be within [0, 1].\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/mobilebert/distillation.py:164 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"}