{"record":{"id":"f98bec3e1f497469","repo":"tensorflow/models","slug":"y-pred-must-be-of-type-twotowertrainingoutputs-b-f98bec","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/uplift_mean.py","lineNumber":89,"sourceCode":"      sample_weight: tf.Tensor | None = None,\n  ) -> None:\n    \"\"\"Updates the overall, control and treatment uplift means.\n\n    Args:\n      y_true: tensor labels.\n      y_pred: two tower training outputs. The treatment indicator tensor is used\n        to slice the uplift prediction into control and treatment groups.\n      sample_weight: optional sample weight to compute weighted uplift means. If\n        given, the sample weight will also be sliced by the treatment indicator\n        tensor to compute the weighted control and treatment uplift means.\n\n    Raises:\n      TypeError: if y_pred is not of type `TwoTowerTrainingOutputs`.\n    \"\"\"\n    del y_true\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._sliced_uplift.update_state(\n        values=y_pred.uplift,\n        is_treatment=y_pred.is_treatment,\n        sample_weight=sample_weight,\n    )\n\n  def result(self) -> dict[str, tf.Tensor]:\n    return self._sliced_uplift.result()\n","sourceCodeStart":71,"sourceCodeEnd":102,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/uplift/metrics/uplift_mean.py#L71-L102","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/uplift_mean.py:89 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"}