From 2e00361522549f922d25c41b1dbfb2a96c6dc8f1 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 1 Aug 2017 22:10:17 +0200 Subject: [PATCH] Fix update when 0 docs --- spacy/language.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spacy/language.py b/spacy/language.py index fad2e2119..0284c4636 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -292,6 +292,11 @@ class Language(object): >>> for docs, golds in epoch: >>> state = nlp.update(docs, golds, sgd=optimizer) """ + if len(docs) != len(golds): + raise IndexError("Update expects same number of docs and golds " + "Got: %d, %d" % (len(docs), len(golds))) + if len(docs) == 0: + return tok2vec = self.pipeline[0] feats = tok2vec.doc2feats(docs) grads = {}