From ffc371350aa5ebeb7b4e6be26d5064993a54db41 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 24 Jan 2021 14:37:33 +1100 Subject: [PATCH] Avoid assuming encode.get_dim('nO') is set in tok2vec (#6800) --- spacy/ml/models/tok2vec.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/ml/models/tok2vec.py b/spacy/ml/models/tok2vec.py index f013d54d4..c4bd6b0d7 100644 --- a/spacy/ml/models/tok2vec.py +++ b/spacy/ml/models/tok2vec.py @@ -101,7 +101,8 @@ def build_Tok2Vec_model( embeddings, using an architecture such as a CNN, BiLSTM or transformer. """ tok2vec = chain(embed, encode) - tok2vec.set_dim("nO", encode.get_dim("nO")) + if encode.has_dim("nO"): + tok2vec.set_dim("nO", encode.get_dim("nO")) tok2vec.set_ref("embed", embed) tok2vec.set_ref("encode", encode) return tok2vec