mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-10 16:22:29 +03:00
Improve parser multi-task objective
This commit is contained in:
parent
fe7d6f36b1
commit
21ee1c7a17
|
@ -13,7 +13,8 @@ from .util import msgpack
|
||||||
from .util import msgpack_numpy
|
from .util import msgpack_numpy
|
||||||
|
|
||||||
from thinc.api import chain
|
from thinc.api import chain
|
||||||
from thinc.v2v import Affine, SELU, Softmax
|
from thinc.v2v import Affine, Maxout, Softmax
|
||||||
|
from thinc.misc import LayerNorm
|
||||||
from thinc.t2v import Pooling, max_pool, mean_pool
|
from thinc.t2v import Pooling, max_pool, mean_pool
|
||||||
from thinc.neural.util import to_categorical, copy_array
|
from thinc.neural.util import to_categorical, copy_array
|
||||||
from thinc.neural._classes.difference import Siamese, CauchySimilarity
|
from thinc.neural._classes.difference import Siamese, CauchySimilarity
|
||||||
|
@ -879,9 +880,10 @@ class MultitaskObjective(Tagger):
|
||||||
@classmethod
|
@classmethod
|
||||||
def Model(cls, n_tags, tok2vec=None, **cfg):
|
def Model(cls, n_tags, tok2vec=None, **cfg):
|
||||||
token_vector_width = util.env_opt('token_vector_width', 96)
|
token_vector_width = util.env_opt('token_vector_width', 96)
|
||||||
softmax = Softmax(n_tags, token_vector_width)
|
softmax = Softmax(n_tags, token_vector_width*2)
|
||||||
model = chain(
|
model = chain(
|
||||||
tok2vec,
|
tok2vec,
|
||||||
|
LayerNorm(Maxout(token_vector_width*2, token_vector_width, pieces=3)),
|
||||||
softmax
|
softmax
|
||||||
)
|
)
|
||||||
model.tok2vec = tok2vec
|
model.tok2vec = tok2vec
|
||||||
|
|
Loading…
Reference in New Issue
Block a user