keras-team/keras · error · ValueError
Unknown loss function: '{loss_item}'.
Error message
Unknown loss function: '{loss_item}'. What it means
Error "Unknown loss function: '{loss_item}'." thrown in keras-team/keras.
Source
Thrown at keras/src/distillation/distillation_loss.py:26
def _convert_loss_to_function(loss_item):
"""Convert a loss string identifier to a loss function.
Arguments:
loss_item: Either a string identifier, a loss function instance,
or `None`.
Returns:
A loss function instance, or `None`.
Raises:
ValueError: If the loss string identifier is unknown.
"""
if loss_item is None:
return None
elif isinstance(loss_item, str):
loss_fn = keras.losses.get(loss_item)
if loss_fn is None:
raise ValueError(f"Unknown loss function: '{loss_item}'.")
return loss_fn
else:
return loss_item
@keras_export("keras.distillation.DistillationLoss")
class DistillationLoss:
"""Base class for distillation loss computation.
Distillation losses define how to compute the distillation loss
between teacher and student outputs. Each loss implements a specific
approach to knowledge transfer, from simple logits matching to feature-based
distillation.
To create custom distillation losses, subclass this class and
override the `compute_loss` method.
"""
View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/distillation/distillation_loss.py:26 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/57da3cc280ccca96.
Report an issue: GitHub.