From 674c39bff9483ffe584d2c95d52d37131c69f279 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 27 Jul 2020 16:48:21 +0200 Subject: [PATCH] fix train_textcat script --- examples/training/train_textcat.py | 6 ++++-- examples/training/train_textcat_config.cfg | 23 +++++++++------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/examples/training/train_textcat.py b/examples/training/train_textcat.py index cb65b8c8b..d94fbfd4a 100644 --- a/examples/training/train_textcat.py +++ b/examples/training/train_textcat.py @@ -20,6 +20,7 @@ import spacy from spacy import util from spacy.util import minibatch, compounding from spacy.gold import Example +from thinc.api import Config @plac.annotations( @@ -42,8 +43,9 @@ def main(config_path, output_dir=None, n_iter=20, n_texts=2000, init_tok2vec=Non output_dir.mkdir() print(f"Loading nlp model from {config_path}") - nlp_config = util.load_config(config_path, create_objects=False)["nlp"] - nlp = util.load_model_from_config(nlp_config) + nlp_config = Config().from_disk(config_path) + print(f"config: {nlp_config}") + nlp, _ = util.load_model_from_config(nlp_config) # ensure the nlp object was defined with a textcat component if "textcat" not in nlp.pipe_names: diff --git a/examples/training/train_textcat_config.cfg b/examples/training/train_textcat_config.cfg index 7c0f36b57..a1f4e91ce 100644 --- a/examples/training/train_textcat_config.cfg +++ b/examples/training/train_textcat_config.cfg @@ -1,19 +1,14 @@ [nlp] lang = "en" +pipeline = ["textcat"] -[nlp.pipeline.textcat] +[components] + +[components.textcat] factory = "textcat" -[nlp.pipeline.textcat.model] -@architectures = "spacy.TextCatCNN.v1" -exclusive_classes = false - -[nlp.pipeline.textcat.model.tok2vec] -@architectures = "spacy.HashEmbedCNN.v1" -pretrained_vectors = null -width = 96 -depth = 4 -embed_size = 2000 -window_size = 1 -maxout_pieces = 3 -subword_features = true +[components.textcat.model] +@architectures = "spacy.TextCatBOW.v1" +exclusive_classes = true +ngram_size = 1 +no_output_layer = false