Update CharacterEmbed function

This commit is contained in:
Matthew Honnibal 2020-07-28 23:06:30 +02:00
parent 6a6b09bd32
commit 00de30bcc2
1 changed files with 9 additions and 8 deletions

View File

@ -119,15 +119,16 @@ def MultiHashEmbed(
@registry.architectures.register("spacy.CharacterEmbed.v1") @registry.architectures.register("spacy.CharacterEmbed.v1")
def CharacterEmbed(columns, width, rows, nM, nC, features, dropout): def CharacterEmbed(width: int, rows: int, nM: int, nC: int):
norm = HashEmbed( model = concatenate(
nO=width, nV=rows, column=columns.index("NORM"), dropout=dropout, seed=5 _character_embed.CharacterEmbed(nM=nM, nC=nC),
chain(
FeatureExtractor([NORM]),
with_array(HashEmbed(nO=width, nV=rows, column=0, seed=5))
) )
chr_embed = _character_embed.CharacterEmbed(nM=nM, nC=nC) )
with Model.define_operators({">>": chain, "|": concatenate}): model.set_dim("nO", nM * nC + width)
embed_layer = chr_embed | features >> with_array(norm) return model
embed_layer.set_dim("nO", nM * nC + width)
return embed_layer
@registry.architectures.register("spacy.MaxoutWindowEncoder.v1") @registry.architectures.register("spacy.MaxoutWindowEncoder.v1")