Allow vector loading to work on 1d data files. Fixes #1831

This commit is contained in:
Matthew Honnibal 2018-01-22 19:18:26 +01:00
parent 00557c5fdd
commit 29897ed1b3
1 changed files with 2 additions and 0 deletions

View File

@ -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_: