From 78396d137fa2faced8a0a612ed5009fa52e3b721 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Tue, 29 Sep 2020 11:57:08 +0200 Subject: [PATCH] Integrate initialize settings --- spacy/language.py | 3 ++- spacy/training/initialize.py | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index 20b7a7256..5ba7e38f8 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1217,9 +1217,10 @@ class Language: name="tokenizer", ) self.tokenizer.initialize(get_examples, nlp=self, **tok_settings) + proc_settings = settings.get("components", {}) for name, proc in self.pipeline: if hasattr(proc, "initialize"): - p_settings = settings.get(name, {}) + p_settings = proc_settings.get(name, {}) p_settings = validate_init_settings( proc.initialize, p_settings, section="components", name=name ) diff --git a/spacy/training/initialize.py b/spacy/training/initialize.py index 9a47a7f69..b42732d48 100644 --- a/spacy/training/initialize.py +++ b/spacy/training/initialize.py @@ -55,9 +55,7 @@ def init_nlp(config: Config, *, use_gpu: int = -1, silent: bool = True) -> Langu msg.info(f"Resuming training for: {resume_components}") nlp.resume_training(sgd=optimizer) with nlp.select_pipes(disable=[*frozen_components, *resume_components]): - nlp.initialize( - lambda: train_corpus(nlp), sgd=optimizer, settings=I["components"] - ) + nlp.initialize(lambda: train_corpus(nlp), sgd=optimizer, settings=I) msg.good("Initialized pipeline components") # Verify the config after calling 'initialize' to ensure labels # are properly initialized