From ece8be4feca968cd294c00e0423d8daceafa639d Mon Sep 17 00:00:00 2001 From: svlandeg Date: Wed, 12 May 2021 11:32:22 +0200 Subject: [PATCH] extend test to training with replaced tok2vec layer --- spacy/tests/pipeline/test_tok2vec.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spacy/tests/pipeline/test_tok2vec.py b/spacy/tests/pipeline/test_tok2vec.py index e3b71c502..7a9e96b14 100644 --- a/spacy/tests/pipeline/test_tok2vec.py +++ b/spacy/tests/pipeline/test_tok2vec.py @@ -218,6 +218,13 @@ def test_replace_listeners(): nlp.replace_listeners("tok2vec", "tagger", ["model.yolo"]) with pytest.raises(ValueError): nlp.replace_listeners("tok2vec", "tagger", ["model.tok2vec", "model.yolo"]) + # attempt training with the new pipeline + optimizer = nlp.initialize(lambda: examples) + for i in range(2): + losses = {} + nlp.update(examples, sgd=optimizer, losses=losses) + assert losses["tok2vec"] == 0.0 + assert losses["tagger"] > 0.0 cfg_string_multi = """