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/treatment_fraction.py:76
y_true: tf.Tensor,
y_pred: types.TwoTowerTrainingOutputs,
sample_weight: tf.Tensor | None = None,
) -> None:
"""Updates the treatment fraction.
Args:
y_true: tensor labels.
y_pred: two tower training outputs. The treatment indicator tensor is used
update the treatment fraction.
sample_weight: optional sample weight tensor for computing the weighted
treatment fraction. The unweighted treatment fraction is computed
instead if it is left as `None`.
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._treatment_fraction.update_state(
values=y_pred.is_treatment, sample_weight=sample_weight
)
def result(self) -> tf.Tensor:
return self._treatment_fraction.result()
View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/recommendation/uplift/metrics/treatment_fraction.py:76 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/bc021b1143a9bbd2.
Report an issue: GitHub.