mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-03 21:24:11 +03:00
Make add parser label work for hidden_depth=0
This commit is contained in:
parent
73bca3d382
commit
3065f12ef2
|
@ -800,11 +800,20 @@ cdef class Parser:
|
||||||
if self.model not in (True, False, None) and resized:
|
if self.model not in (True, False, None) and resized:
|
||||||
# Weights are stored in (nr_out, nr_in) format, so we're basically
|
# Weights are stored in (nr_out, nr_in) format, so we're basically
|
||||||
# just adding rows here.
|
# just adding rows here.
|
||||||
smaller = self.model[-1]._layers[-1]
|
if self.model[-1].is_noop:
|
||||||
larger = Affine(self.moves.n_moves, smaller.nI)
|
smaller = self.model[1]
|
||||||
copy_array(larger.W[:smaller.nO], smaller.W)
|
dims = dict(self.model[1]._dims)
|
||||||
copy_array(larger.b[:smaller.nO], smaller.b)
|
dims['nO'] = self.moves.n_moves
|
||||||
self.model[-1]._layers[-1] = larger
|
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
|
||||||
|
|
||||||
def begin_training(self, gold_tuples, pipeline=None, **cfg):
|
def begin_training(self, gold_tuples, pipeline=None, **cfg):
|
||||||
if 'model' in cfg:
|
if 'model' in cfg:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user