Unverified Commit c08a1e26 authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Adapt has_labels test when no labels were found (#20113)

* Make default labels for non-pretrained models

* Fix the has_labels test instead
parent e2a23b6c
......@@ -3189,7 +3189,7 @@ class Trainer:
Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor]]: A tuple with the loss,
logits and labels (each being optional).
"""
has_labels = all(inputs.get(k) is not None for k in self.label_names)
has_labels = False if len(self.label_names) == 0 else all(inputs.get(k) is not None for k in self.label_names)
inputs = self._prepare_inputs(inputs)
if ignore_keys is None:
if hasattr(self.model, "config"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment