Avoid assuming encode.get_dim('nO') is set in tok2vec (#6800)

This commit is contained in:
Matthew Honnibal 2021-01-24 14:37:33 +11:00 committed by GitHub
parent 0a86d833d7
commit ffc371350a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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