Integrate initialize settings

This commit is contained in:
Ines Montani 2020-09-29 11:57:08 +02:00
parent dec984a9c1
commit 78396d137f
2 changed files with 3 additions and 4 deletions

View File

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

View File

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