tensorflow/models · error · TypeError
y_pred must be of type `TwoTowerTrainingOutputs` but got typ
Error message
y_pred must be of type `TwoTowerTrainingOutputs` but got type {type(y_pred)} instead. What it means
Error "y_pred must be of type `TwoTowerTrainingOutputs` but got type {type(y_pred)} instead." thrown in tensorflow/models.
Source
Thrown at official/recommendation/uplift/metrics/uplift_mean.py:89
sample_weight: tf.Tensor | None = None,
) -> None:
"""Updates the overall, control and treatment uplift means.
Args:
y_true: tensor labels.
y_pred: two tower training outputs. The treatment indicator tensor is used
to slice the uplift prediction into control and treatment groups.
sample_weight: optional sample weight to compute weighted uplift means. If
given, the sample weight will also be sliced by the treatment indicator
tensor to compute the weighted control and treatment uplift means.
Raises:
TypeError: if y_pred is not of type `TwoTowerTrainingOutputs`.
"""
del y_true
if not isinstance(y_pred, types.TwoTowerTrainingOutputs):
raise TypeError(
"y_pred must be of type `TwoTowerTrainingOutputs` but got type"
f" {type(y_pred)} instead."
)
self._sliced_uplift.update_state(
values=y_pred.uplift,
is_treatment=y_pred.is_treatment,
sample_weight=sample_weight,
)
def result(self) -> dict[str, tf.Tensor]:
return self._sliced_uplift.result()
View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/recommendation/uplift/metrics/uplift_mean.py:89 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/f98bec3e1f497469.
Report an issue: GitHub.