From 511ced11ff483a18887a8426f2d2e36fb2cb5934 Mon Sep 17 00:00:00 2001 From: Matthw Honnibal Date: Tue, 19 Nov 2019 11:17:33 +0100 Subject: [PATCH] Fix char embed+vectors in ml --- spacy/ml/_legacy_tok2vec.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spacy/ml/_legacy_tok2vec.py b/spacy/ml/_legacy_tok2vec.py index b077a46b7..3e41b1c6a 100644 --- a/spacy/ml/_legacy_tok2vec.py +++ b/spacy/ml/_legacy_tok2vec.py @@ -49,6 +49,14 @@ def Tok2Vec(width, embed_size, **kwargs): >> LN(Maxout(width, width * 5, pieces=3)), column=cols.index(ORTH), ) + elif char_embed: + embed = concatenate_lists( + CharacterEmbed(nM=64, nC=8), + FeatureExtracter(cols) >> with_flatten(glove), + ) + reduce_dimensions = LN( + Maxout(width, 64 * 8 + width, pieces=cnn_maxout_pieces) + ) else: embed = uniqued( (glove | norm) >> LN(Maxout(width, width * 2, pieces=3)), @@ -81,7 +89,8 @@ def Tok2Vec(width, embed_size, **kwargs): ) else: tok2vec = FeatureExtracter(cols) >> with_flatten( - embed >> convolution ** conv_depth, pad=conv_depth + embed + >> convolution ** conv_depth, pad=conv_depth ) if bilstm_depth >= 1: