{"record":{"id":"bc021b1143a9bbd2","repo":"tensorflow/models","slug":"y-pred-must-be-of-type-twotowertrainingoutputs-b-bc021b","errorCode":null,"errorMessage":"y_pred must be of type `TwoTowerTrainingOutputs` but got type {type(y_pred)} instead.","messagePattern":"y_pred must be of type `TwoTowerTrainingOutputs` but got type (.+?) instead\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"official/recommendation/uplift/metrics/treatment_fraction.py","lineNumber":76,"sourceCode":"      y_true: tf.Tensor,\n      y_pred: types.TwoTowerTrainingOutputs,\n      sample_weight: tf.Tensor | None = None,\n  ) -> None:\n    \"\"\"Updates the treatment fraction.\n\n    Args:\n      y_true: tensor labels.\n      y_pred: two tower training outputs. The treatment indicator tensor is used\n        update the treatment fraction.\n      sample_weight: optional sample weight tensor for computing the weighted\n        treatment fraction. The unweighted treatment fraction is computed\n        instead if it is left as `None`.\n\n    Raises:\n      TypeError: if y_pred is not of type `TwoTowerTrainingOutputs`.\n    \"\"\"\n    if not isinstance(y_pred, types.TwoTowerTrainingOutputs):\n      raise TypeError(\n          \"y_pred must be of type `TwoTowerTrainingOutputs` but got type\"\n          f\" {type(y_pred)} instead.\"\n      )\n\n    self._treatment_fraction.update_state(\n        values=y_pred.is_treatment, sample_weight=sample_weight\n    )\n\n  def result(self) -> tf.Tensor:\n    return self._treatment_fraction.result()\n","sourceCodeStart":58,"sourceCodeEnd":87,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/uplift/metrics/treatment_fraction.py#L58-L87","documentation":"Error \"y_pred must be of type `TwoTowerTrainingOutputs` but got type {type(y_pred)} instead.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/recommendation/uplift/metrics/treatment_fraction.py:76 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"}