Skip to content

Commit

Permalink
Merge pull request #154 from zalandoresearch/GH-149-predict-clear-emb…
Browse files Browse the repository at this point in the history
…eddings

GH-149: Always clear embeddings in predict
  • Loading branch information
Alan Akbik committed Oct 18, 2018
2 parents dd062de + ddafc03 commit cb09e3b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions flair/models/text_classification_model.py
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit cb09e3b

Please sign in to comment.