diff --git a/spacy/pipeline/entity_linker.py b/spacy/pipeline/entity_linker.py index 6ea735dde..262bcf677 100644 --- a/spacy/pipeline/entity_linker.py +++ b/spacy/pipeline/entity_linker.py @@ -273,7 +273,7 @@ class EntityLinker(TrainablePipe): gradients = self.distance.get_grad(sentence_encodings, entity_encodings) loss = self.distance.get_loss(sentence_encodings, entity_encodings) loss = loss / len(entity_encodings) - return loss, gradients + return float(loss), gradients def predict(self, docs: Iterable[Doc]) -> List[str]: """Apply the pipeline's model to a batch of docs, without modifying them. diff --git a/spacy/pipeline/multitask.pyx b/spacy/pipeline/multitask.pyx index cfb492612..990b6a1de 100644 --- a/spacy/pipeline/multitask.pyx +++ b/spacy/pipeline/multitask.pyx @@ -197,7 +197,7 @@ class ClozeMultitask(TrainablePipe): target = vectors[ids] gradient = self.distance.get_grad(prediction, target) loss = self.distance.get_loss(prediction, target) - return loss, gradient + return float(loss), gradient def update(self, examples, *, drop=0., sgd=None, losses=None): pass