Skip to content

Commit ffc3713

Browse files
authored
Avoid assuming encode.get_dim('nO') is set in tok2vec (explosion#6800)
1 parent 0a86d83 commit ffc3713

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spacy/ml/models/tok2vec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def build_Tok2Vec_model(
101101
embeddings, using an architecture such as a CNN, BiLSTM or transformer.
102102
"""
103103
tok2vec = chain(embed, encode)
104-
tok2vec.set_dim("nO", encode.get_dim("nO"))
104+
if encode.has_dim("nO"):
105+
tok2vec.set_dim("nO", encode.get_dim("nO"))
105106
tok2vec.set_ref("embed", embed)
106107
tok2vec.set_ref("encode", encode)
107108
return tok2vec

0 commit comments

Comments
 (0)