{"record":{"id":"4b00627e96f9c69a","repo":"tensorflow/models","slug":"y-pred-must-be-of-type-twotowertrainingoutputs-b","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/label_mean.py","lineNumber":90,"sourceCode":"      y_true: tf.Tensor,\n      y_pred: types.TwoTowerTrainingOutputs,\n      sample_weight: tf.Tensor | None = None,\n  ):\n    \"\"\"Updates the overall, control and treatment label means.\n\n    Args:\n      y_true: tensor labels.\n      y_pred: prediction logits. The treatment indicator tensor is used to slice\n        the labels into control and treatment groups.\n      sample_weight: optional sample weight to compute weighted label means. If\n        given, the sample weight will also be sliced by the treatment indicator\n        tensor to compute the weighted control and treatment label means.\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._sliced_mean.update_state(\n        values=y_true,\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_mean.result()\n","sourceCodeStart":72,"sourceCodeEnd":103,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/uplift/metrics/label_mean.py#L72-L103","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/label_mean.py:90 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"}