Pass Tok2Vec settings a bit better

This commit is contained in:
Matthw Honnibal 2019-10-21 01:11:47 +02:00
parent fef50277d7
commit b4e0040d10

View File

@ -406,15 +406,11 @@ def Tok2Vec(width, embed_size, **kwargs):
pretrained_vectors = kwargs.get("pretrained_vectors", None)
cnn_maxout_pieces = kwargs.get("cnn_maxout_pieces", 3)
subword_features = kwargs.get("subword_features", True)
char_embed = util.env_opt("char_embed", kwargs.get("char_embed", False))
char_embed = kwargs.get("char_embed", False)
conv_depth = kwargs.get("conv_depth", 4)
bilstm_depth = util.env_opt("bilstm_depth", kwargs.get("bilstm_depth", 0))
self_attn_depth = util.env_opt("self_attn_depth", kwargs.get("self_attn_depth", 0))
conv_window = util.env_opt("conv_window", kwargs.get("cnn_window", 1))
kwargs.setdefault("bilstm_depth", bilstm_depth)
kwargs.setdefault("self_attn_depth", self_attn_depth)
kwargs.setdefault("char_embed", char_embed)
kwargs.setdefault("conv_window", conv_window)
bilstm_depth = kwargs.get("bilstm_depth", 0)
self_attn_depth = kwargs.get("self_attn_depth", 0)
conv_window = kwargs.get("conv_window", 1)
if char_embed and self_attn_depth:
return Tok2Vec_chars_selfattention(width, embed_size, **kwargs)
elif char_embed and bilstm_depth: