diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index dd52c4cbf..b9941b50b 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -304,7 +304,10 @@ cdef class Doc: if self._vector is not None: return self._vector elif self.has_vector and len(self): - self._vector = sum(t.vector for t in self) / len(self) + vector = numpy.zeros((self.vocab.vectors_length,), dtype='f') + for token in self.c[:self.length]: + vector += self.vocab.get_vector(token.lex.orth) + self._vector = vector / len(self) return self._vector elif self.tensor is not None: self._vector = self.tensor.mean(axis=0)