From ddafc0356f19f854a4b2d780f48923cfab5b3d8c Mon Sep 17 00:00:00 2001 From: tabergma Date: Thu, 18 Oct 2018 13:36:36 +0200 Subject: [PATCH] GH-149: Always clear embeddings after predict. --- flair/models/text_classification_model.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/flair/models/text_classification_model.py b/flair/models/text_classification_model.py index 51323542f..fd68761c3 100644 --- a/flair/models/text_classification_model.py +++ b/flair/models/text_classification_model.py @@ -99,7 +99,7 @@ def load_from_file(cls, model_file): model.eval() return model - def predict(self, sentences: Union[Sentence, List[Sentence]], mini_batch_size: int = 32, embeddings_in_memory: bool = True) -> List[Sentence]: + def predict(self, sentences: Union[Sentence, List[Sentence]], mini_batch_size: int = 32) -> List[Sentence]: """ Predicts the class labels for the given sentences. The labels are directly added to the sentences. :param sentences: list of sentences @@ -118,8 +118,7 @@ def predict(self, sentences: Union[Sentence, List[Sentence]], mini_batch_size: i for (sentence, labels) in zip(batch, predicted_labels): sentence.labels = labels - if not embeddings_in_memory: - clear_embeddings(batch) + clear_embeddings(batch) return sentences