{"record":{"id":"00281438d0ebd1f1","repo":"tensorflow/models","slug":"at-most-one-of-hub-module-url-and-init-checkpoi-002814","errorCode":null,"errorMessage":"At most one of `hub_module_url` and `init_checkpoint` can be specified.","messagePattern":"At most one of `hub_module_url` and `init_checkpoint` can be specified\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/tasks/tagging.py","lineNumber":87,"sourceCode":"    (masked_y_true, masked_weights) where `masked_y_true` is the input\n    with each negative label replaced with zero and `masked_weights` is 0.0\n    where negative labels were replaced and 1.0 for original labels.\n  \"\"\"\n  # Ignore the classes of tokens with negative values.\n  mask = tf.greater_equal(y_true, 0)\n  # Replace negative labels, which are out of bounds for some loss functions,\n  # with zero.\n  masked_y_true = tf.where(mask, y_true, 0)\n  return masked_y_true, tf.cast(mask, tf.float32)\n\n\n@task_factory.register_task_cls(TaggingConfig)\nclass TaggingTask(base_task.Task):\n  \"\"\"Task object for tagging (e.g., NER or POS).\"\"\"\n\n  def build_model(self):\n    if self.task_config.hub_module_url and self.task_config.init_checkpoint:\n      raise ValueError('At most one of `hub_module_url` and '\n                       '`init_checkpoint` can be specified.')\n    if self.task_config.hub_module_url:\n      encoder_network = utils.get_encoder_from_hub(\n          self.task_config.hub_module_url)\n    else:\n      encoder_network = encoders.build_encoder(self.task_config.model.encoder)\n\n    return models.BertTokenClassifier(\n        network=encoder_network,\n        num_classes=len(self.task_config.class_names),\n        initializer=tf_keras.initializers.TruncatedNormal(\n            stddev=self.task_config.model.head_initializer_range),\n        dropout_rate=self.task_config.model.head_dropout,\n        output='logits',\n        output_encoder_outputs=True)\n\n  def build_losses(self, labels, model_outputs, aux_losses=None) -> tf.Tensor:\n    logits = tf.cast(model_outputs['logits'], tf.float32)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/tasks/tagging.py#L69-L105","documentation":"Error \"At most one of `hub_module_url` and `init_checkpoint` can be specified.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/tasks/tagging.py:87 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"}