{"record":{"id":"fed38b989b22b181","repo":"tensorflow/models","slug":"transfer-teacher-layers-is-not-specified-and-th","errorCode":null,"errorMessage":"`transfer_teacher_layers` is not specified, and the number of teacher layers does not match the number of student layers.","messagePattern":"`transfer_teacher_layers` is not specified, and the number of teacher layers does not match the number of student layers\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/mobilebert/distillation.py","lineNumber":158,"sourceCode":"    self._train_data_config = task_config.train_data\n    self._eval_data_config = task_config.validation_data\n    self._the_only_train_dataset = None\n    self._the_only_eval_dataset = None\n\n    layer_wise_config = self._progressive_config.layer_wise_distill_config\n    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(","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/mobilebert/distillation.py#L140-L176","documentation":"Error \"`transfer_teacher_layers` is not specified, and the number of teacher layers does not match the number of student layers.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/mobilebert/distillation.py:158 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"}