{"record":{"id":"99154c76f911f4f5","repo":"tensorflow/models","slug":"only-all-or-backbone-can-be-used-to-initialize-99154c","errorCode":null,"errorMessage":"Only 'all' or 'backbone' can be used to initialize the model.","messagePattern":"Only 'all' or 'backbone' can be used to initialize the model\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/tasks/video_classification.py","lineNumber":101,"sourceCode":"    \"\"\"Loads pretrained checkpoint.\"\"\"\n    if not self.task_config.init_checkpoint:\n      return\n\n    ckpt_dir_or_file = self.task_config.init_checkpoint\n    if tf.io.gfile.isdir(ckpt_dir_or_file):\n      ckpt_dir_or_file = tf.train.latest_checkpoint(ckpt_dir_or_file)\n\n    # Restoring checkpoint.\n    if self.task_config.init_checkpoint_modules == 'all':\n      ckpt = tf.train.Checkpoint(model=model)\n      status = ckpt.read(ckpt_dir_or_file)\n      status.expect_partial().assert_existing_objects_matched()\n    elif self.task_config.init_checkpoint_modules == 'backbone':\n      ckpt = tf.train.Checkpoint(backbone=model.backbone)\n      status = ckpt.read(ckpt_dir_or_file)\n      status.expect_partial().assert_existing_objects_matched()\n    else:\n      raise ValueError(\n          \"Only 'all' or 'backbone' can be used to initialize the model.\")\n\n    logging.info('Finished loading pretrained checkpoint from %s',\n                 ckpt_dir_or_file)\n\n  def _get_dataset_fn(self, params):\n    if params.file_type == 'tfrecord':\n      return tf.data.TFRecordDataset\n    else:\n      raise ValueError('Unknown input file type {!r}'.format(params.file_type))\n\n  def _get_decoder_fn(self, params):\n    if params.tfds_name:\n      decoder = video_input.VideoTfdsDecoder(\n          image_key=params.image_field_key, label_key=params.label_field_key)\n    else:\n      decoder = video_input.Decoder(\n          image_key=params.image_field_key, label_key=params.label_field_key)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/tasks/video_classification.py#L83-L119","documentation":"Error \"Only 'all' or 'backbone' can be used to initialize the model.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/tasks/video_classification.py:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the initialization mode to 'all' or 'backbone' when loading video classification weights.","Check the init_checkpoint_modules config value."],"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"}