From 165e37808229bc4d67889589cdab3b2e5ebe5bfd Mon Sep 17 00:00:00 2001 From: Matthw Honnibal Date: Sun, 27 Oct 2019 22:19:10 +0100 Subject: [PATCH] Fix tok2vec arch after refactor --- spacy/ml/common.py | 2 +- spacy/ml/tok2vec.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/ml/common.py b/spacy/ml/common.py index 168ede0fe..9c9328d72 100644 --- a/spacy/ml/common.py +++ b/spacy/ml/common.py @@ -17,6 +17,6 @@ def FeedForward(config): def LayerNormalizedMaxout(config): width = config["width"] pieces = config["pieces"] - layer = chain(Maxout(width, pieces=pieces), LayerNorm(nO=width)) + layer = LayerNorm(Maxout(width, pieces=pieces)) layer.nO = width return layer diff --git a/spacy/ml/tok2vec.py b/spacy/ml/tok2vec.py index e5696ecc2..058feb551 100644 --- a/spacy/ml/tok2vec.py +++ b/spacy/ml/tok2vec.py @@ -14,10 +14,12 @@ from .common import * @register_architecture("spacy.Tok2Vec.v1") def Tok2Vec(config): + print(config) doc2feats = make_layer(config["@doc2feats"]) embed = make_layer(config["@embed"]) encode = make_layer(config["@encode"]) - tok2vec = chain(doc2feats, with_flatten(chain(embed, encode))) + depth = config["@encode"]["config"]["depth"] + tok2vec = chain(doc2feats, with_flatten(chain(embed, encode), pad=depth)) tok2vec.cfg = config tok2vec.nO = encode.nO tok2vec.embed = embed @@ -81,8 +83,7 @@ def MaxoutWindowEncoder(config): cnn = chain( ExtractWindow(nW=nW), - Maxout(nO, nO * ((nW * 2) + 1), pieces=nP), - LayerNorm(nO=nO), + LayerNorm(Maxout(nO, nO * ((nW * 2) + 1), pieces=nP)), ) model = clone(Residual(cnn), depth) model.nO = nO