From 75903949da06130d85afc1d35bd1f6d2758adb9f Mon Sep 17 00:00:00 2001 From: Avadh Patel Date: Thu, 18 Jan 2018 06:51:57 -0600 Subject: [PATCH] Updated model building after suggestion from Matthew Signed-off-by: Avadh Patel --- spacy/syntax/nn_parser.pyx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index 7a722ae36..40485d45d 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -259,10 +259,6 @@ cdef class Parser: zero_init(Affine(nr_class, hidden_width, drop_factor=0.0)) ) - # TODO: This is an unfortunate hack atm! - # Used to set input dimensions in network. - if not cfg.get('from_disk', False): - lower.begin_training(lower.ops.allocate((500, token_vector_width))) cfg = { 'nr_class': nr_class, 'hidden_depth': depth, @@ -812,6 +808,8 @@ cdef class Parser: self.model, cfg = self.Model(self.moves.n_moves, **cfg) if sgd is None: sgd = self.create_optimizer() + self.model[1].begin_training( + self.model[1].ops.allocate((5, cfg['token_vector_width']))) self.init_multitask_objectives(gold_tuples, pipeline, sgd=sgd, **cfg) link_vectors_to_models(self.vocab) self.cfg.update(cfg) @@ -865,7 +863,7 @@ cdef class Parser: path = util.ensure_path(path) if self.model is True: self.cfg['pretrained_dims'] = self.vocab.vectors_length - self.model, cfg = self.Model(from_disk=True, **self.cfg) + self.model, cfg = self.Model(**self.cfg) else: cfg = {} with (path / 'tok2vec_model').open('rb') as file_: