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/label_mean.py:90
y_true: tf.Tensor,
y_pred: types.TwoTowerTrainingOutputs,
sample_weight: tf.Tensor | None = None,
):
"""Updates the overall, control and treatment label means.
Args:
y_true: tensor labels.
y_pred: prediction logits. The treatment indicator tensor is used to slice
the labels into control and treatment groups.
sample_weight: optional sample weight to compute weighted label means. If
given, the sample weight will also be sliced by the treatment indicator
tensor to compute the weighted control and treatment label means.
Raises:
TypeError: if y_pred is not of type `TwoTowerTrainingOutputs`.
"""
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_mean.update_state(
values=y_true,
is_treatment=y_pred.is_treatment,
sample_weight=sample_weight,
)
def result(self) -> dict[str, tf.Tensor]:
return self._sliced_mean.result()
View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/recommendation/uplift/metrics/label_mean.py:90 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/4b00627e96f9c69a.
Report an issue: GitHub.