mirror of https://github.com/explosion/spaCy.git
Refactor Tok2Vec
This commit is contained in:
parent
217e7891cd
commit
3fa76c17d1
16
spacy/_ml.py
16
spacy/_ml.py
|
@ -242,20 +242,24 @@ def Tok2Vec(width, embed_size, pretrained_dims=0):
|
|||
>> LN(Maxout(width, width*4, pieces=3)), column=5)
|
||||
)
|
||||
)
|
||||
if pretrained_dims >= 1:
|
||||
embed = concatenate_lists(trained_vectors, SpacyVectors)
|
||||
else:
|
||||
embed = trained_vectors
|
||||
convolution = Residual(ExtractWindow(nW=1) >> LN(Maxout(width, width*3, pieces=3)))
|
||||
|
||||
if pretrained_dims >= 1:
|
||||
embed = concatenate_lists(trained_vectors, SpacyVectors)
|
||||
tok2vec = (
|
||||
embed
|
||||
>> with_flatten(
|
||||
(Affine(width, width+pretrained_dims)
|
||||
if pretrained_dims else noop())
|
||||
Affine(width, width+pretrained_dims)
|
||||
>> convolution ** 4,
|
||||
pad=4)
|
||||
)
|
||||
else:
|
||||
embed = trained_vectors
|
||||
tok2vec = (
|
||||
embed
|
||||
>> with_flatten(convolution ** 4, pad=4)
|
||||
)
|
||||
|
||||
# Work around thinc API limitations :(. TODO: Revise in Thinc 7
|
||||
tok2vec.nO = width
|
||||
tok2vec.embed = embed
|
||||
|
|
Loading…
Reference in New Issue