{"record":{"id":"f6397b146ce1d757","repo":"tensorflow/models","slug":"not-supported-loss-mode-loss-mode","errorCode":null,"errorMessage":"Not supported loss mode: {loss_mode}","messagePattern":"Not supported loss mode: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/unified_detector/modeling/universal_detector.py","lineNumber":855,"sourceCode":"        tf.reduce_sum(pointwise_loss * pos_mask) /\n        (tf.reduce_sum(pos_mask) + EPSILON))\n    # neg\n    neg_mask = gt_affinity_mask * (1. - gt_affinity[:, 0])\n    neg_loss = (\n        tf.reduce_sum(pointwise_loss * neg_mask) /\n        (tf.reduce_sum(neg_mask) + EPSILON))\n    loss = 0.25 * pos_loss + 0.75 * neg_loss\n  elif loss_mode == \"focal\":\n    alpha_wt = fl_alpha * gt_affinity + (1. - fl_alpha) * (1. - gt_affinity)\n    prob_pos = tf.math.sigmoid(affinity / tau)\n    pt = prob_pos * gt_affinity + (1. - prob_pos) * (1. - gt_affinity)\n    fl_loss_pw = tf.stop_gradient(\n        alpha_wt * tf.pow(1. - pt, fl_gamma))[:, 0] * pointwise_loss\n    loss = (\n        tf.reduce_sum(fl_loss_pw * gt_affinity_mask) /\n        (tf.reduce_sum(gt_affinity_mask) + EPSILON))\n  else:\n    raise ValueError(f\"Not supported loss mode: {loss_mode}\")\n\n  loss_dict[\"loss_para\"] = loss\n\n\ndef _mask_id_xent_loss(loss_dict: Dict[str, Any], labels: Dict[str, Any],\n                       outputs: Dict[str, Any]):\n  \"\"\"Mask ID loss.\n\n  This method adds the mask ID loss term to loss_dict directly.\n\n  Args:\n    loss_dict: A dictionary for the loss. The values are loss scalars.\n    labels: The label dictionary.\n    outputs: The output dictionary.\n  \"\"\"\n  # (B, N, H, W)\n  mask_gt = labels[\"masks\"]\n  # B, H, W, N","sourceCodeStart":837,"sourceCodeEnd":873,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/unified_detector/modeling/universal_detector.py#L837-L873","documentation":"Error \"Not supported loss mode: {loss_mode}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/unified_detector/modeling/universal_detector.py:855 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"}