mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-24 08:14:15 +03:00
Switch to single matmul for state layer
This commit is contained in:
parent
700979fb3c
commit
12039e80ca
|
@ -1,5 +1,5 @@
|
||||||
from thinc.api import add, layerize, chain, clone, concatenate, with_flatten
|
from thinc.api import add, layerize, chain, clone, concatenate, with_flatten
|
||||||
from thinc.neural import Model, Maxout, Softmax, Affine
|
from thinc.neural import Model, ReLu, Maxout, Softmax, Affine
|
||||||
from thinc.neural._classes.hash_embed import HashEmbed
|
from thinc.neural._classes.hash_embed import HashEmbed
|
||||||
|
|
||||||
from thinc.neural._classes.convolution import ExtractWindow
|
from thinc.neural._classes.convolution import ExtractWindow
|
||||||
|
@ -37,6 +37,7 @@ def build_debug_model(state2vec, width, depth, nr_class):
|
||||||
with Model.define_operators({'>>': chain, '**': clone}):
|
with Model.define_operators({'>>': chain, '**': clone}):
|
||||||
model = (
|
model = (
|
||||||
state2vec
|
state2vec
|
||||||
|
#>> Maxout(width)
|
||||||
>> Maxout(nr_class)
|
>> Maxout(nr_class)
|
||||||
)
|
)
|
||||||
return model
|
return model
|
||||||
|
@ -64,8 +65,9 @@ def build_debug_state2vec(width, nr_vector=1000, nF=1, nB=0, nS=1, nL=2, nR=2):
|
||||||
def build_state2vec(nr_context_tokens, width, nr_vector=1000):
|
def build_state2vec(nr_context_tokens, width, nr_vector=1000):
|
||||||
ops = Model.ops
|
ops = Model.ops
|
||||||
with Model.define_operators({'|': concatenate, '+': add, '>>': chain}):
|
with Model.define_operators({'|': concatenate, '+': add, '>>': chain}):
|
||||||
hiddens = [get_col(i) >> Maxout(width) for i in range(nr_context_tokens)]
|
#hiddens = [get_col(i) >> Maxout(width) for i in range(nr_context_tokens)]
|
||||||
model = get_token_vectors >> add(*hiddens)
|
features = [get_col(i) for i in range(nr_context_tokens)]
|
||||||
|
model = get_token_vectors >> concatenate(*features) >> ReLu(width)
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user