From 85c942a6e3029d30e97c041eebdb9832ed175cde Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 23 Jan 2018 19:10:49 +0100 Subject: [PATCH] Dont overwrite pretrained_dims setting from cfg. Fixes #1727 --- spacy/pipeline.pyx | 4 ++-- spacy/syntax/nn_parser.pyx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/pipeline.pyx b/spacy/pipeline.pyx index 4b64401cd..529a8b468 100644 --- a/spacy/pipeline.pyx +++ b/spacy/pipeline.pyx @@ -532,7 +532,7 @@ class Tagger(Pipe): else: serialize['model'] = self.model.to_bytes serialize['vocab'] = self.vocab.to_bytes - + serialize['cfg'] = lambda: ujson.dumps(self.cfg) tag_map = OrderedDict(sorted(self.vocab.morphology.tag_map.items())) serialize['tag_map'] = lambda: msgpack.dumps( tag_map, use_bin_type=True, encoding='utf8') @@ -565,7 +565,7 @@ class Tagger(Pipe): return self def to_disk(self, path, **exclude): - self.cfg['pretrained_dims'] = self.vocab.vectors.data.shape[1] + self.cfg.setdefault('pretrained_dims', self.vocab.vectors.data.shape[1]) tag_map = OrderedDict(sorted(self.vocab.morphology.tag_map.items())) serialize = OrderedDict(( ('vocab', lambda p: self.vocab.to_disk(p)), diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index 5c71fb96c..653235aff 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -892,7 +892,7 @@ cdef class Parser: if 'model' not in exclude: path = util.ensure_path(path) if self.model is True: - self.cfg['pretrained_dims'] = self.vocab.vectors_length + self.cfg.setdefault('pretrained_dims', self.vocab.vectors_length) self.model, cfg = self.Model(**self.cfg) else: cfg = {}