tensorflow/models · error · ValueError
Value passed to `from_logits` ({from_logits}) is conflicting
Error message
Value passed to `from_logits` ({from_logits}) is conflicting with the `from_logits` value passed to the `loss_fn` metric ({metric_from_logits}). Ensure that they have the same value. What it means
Error "Value passed to `from_logits` ({from_logits}) is conflicting with the `from_logits` value passed to the `loss_fn` metric ({metric_from_logits}). Ensure that they have the same value." thrown in tensorflow/models.
Source
Thrown at official/recommendation/uplift/metrics/loss_metric.py:111
"`loss_fn` cannot be a Keras `Loss` object, pass a non-reducing loss"
" function or a metric instance instead."
)
if isinstance(loss_fn, tf_keras.metrics.Metric):
name = loss_fn.name
dtype = loss_fn.dtype
super().__init__(name=name, dtype=dtype)
self._loss_fn = loss_fn
self._from_logits = from_logits
self._loss_fn_kwargs = loss_fn_kwargs
self._slice_by_treatment = slice_by_treatment
if isinstance(loss_fn, tf_keras.metrics.Metric):
metric_from_logits = loss_fn.get_config().get("from_logits", from_logits)
if from_logits != metric_from_logits:
raise ValueError(
f"Value passed to `from_logits` ({from_logits}) is conflicting with"
" the `from_logits` value passed to the `loss_fn` metric"
f" ({metric_from_logits}). Ensure that they have the same value."
)
loss_metric = loss_fn
else:
if "from_logits" in inspect.signature(loss_fn).parameters:
self._loss_fn_kwargs.update({"from_logits": from_logits})
loss_metric = tf_keras.metrics.Mean(name=name, dtype=dtype)
if slice_by_treatment:
self._loss = treatment_sliced_metric.TreatmentSlicedMetric(loss_metric)
else:
self._loss = loss_metric
def update_state(
self,View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/recommendation/uplift/metrics/loss_metric.py:111 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/8c356ef0bab732ab.
Report an issue: GitHub.