From 29897ed1b34512bcf1bad11a4c0b83add0602d01 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 22 Jan 2018 19:18:26 +0100 Subject: [PATCH] Allow vector loading to work on 1d data files. Fixes #1831 --- spacy/vectors.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spacy/vectors.pyx b/spacy/vectors.pyx index 96a9d3435..079f6fc84 100644 --- a/spacy/vectors.pyx +++ b/spacy/vectors.pyx @@ -310,6 +310,8 @@ cdef class Vectors: self.data = xp.fromfile(file_, dtype=dtype) if dtype != 'float32': self.data = xp.ascontiguousarray(self.data, dtype='float32') + if self.data.ndim == 1: + self.data = self.data.reshape((self.data.size//width, width)) n = 0 strings = StringStore() with (path / 'vocab.txt').open('r') as file_: