From 15e5a04a8d9a1be29844332295eea85bedae12fc Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 19 Oct 2017 01:48:43 +0200 Subject: [PATCH] Clean up more depth=0 conditional code --- spacy/syntax/nn_parser.pyx | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index f79837fae..cb26b8d37 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -38,7 +38,7 @@ from murmurhash.mrmr cimport hash64 from preshed.maps cimport MapStruct from preshed.maps cimport map_get -from thinc.api import layerize, chain, noop, clone, with_flatten +from thinc.api import layerize, chain, clone, with_flatten from thinc.v2v import Model, Maxout, Softmax, Affine, ReLu, SELU from thinc.misc import LayerNorm @@ -768,20 +768,11 @@ cdef class Parser: if self.model not in (True, False, None) and resized: # Weights are stored in (nr_out, nr_in) format, so we're basically # just adding rows here. - if self.model[-1].is_noop: - smaller = self.model[1] - dims = dict(self.model[1]._dims) - dims['nO'] = self.moves.n_moves - larger = self.model[1].__class__(**dims) - copy_array(larger.W[:, :smaller.nO], smaller.W) - copy_array(larger.b[:smaller.nO], smaller.b) - self.model = (self.model[0], larger, self.model[2]) - else: - smaller = self.model[-1]._layers[-1] - larger = Affine(self.moves.n_moves, smaller.nI) - copy_array(larger.W[:smaller.nO], smaller.W) - copy_array(larger.b[:smaller.nO], smaller.b) - self.model[-1]._layers[-1] = larger + smaller = self.model[-1]._layers[-1] + larger = Affine(self.moves.n_moves, smaller.nI) + copy_array(larger.W[:smaller.nO], smaller.W) + copy_array(larger.b[:smaller.nO], smaller.b) + self.model[-1]._layers[-1] = larger def begin_training(self, gold_tuples, pipeline=None, **cfg): if 'model' in cfg: