From 3cdee79a0ca24d4262f1a7444050485d107a6d4a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 16 Mar 2018 12:37:31 +0100 Subject: [PATCH] Add depth argument for text classifier --- spacy/_ml.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/_ml.py b/spacy/_ml.py index 7b2b5f559..0f5cb8ed8 100644 --- a/spacy/_ml.py +++ b/spacy/_ml.py @@ -450,6 +450,7 @@ def SpacyVectors(docs, drop=0.): def build_text_classifier(nr_class, width=64, **cfg): + depth = cfg.get('depth', 2) nr_vector = cfg.get('nr_vector', 5000) pretrained_dims = cfg.get('pretrained_dims', 0) with Model.define_operators({'>>': chain, '+': add, '|': concatenate, @@ -501,7 +502,7 @@ def build_text_classifier(nr_class, width=64, **cfg): LN(Maxout(width, vectors_width)) >> Residual( (ExtractWindow(nW=1) >> LN(Maxout(width, width*3))) - ) ** 2, pad=2 + ) ** depth, pad=depth ) >> flatten_add_lengths >> ParametricAttention(width)