From e91485dfc464744d1c2d1ea9e648efeea9e403a1 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Wed, 3 Jun 2020 10:04:16 +0200 Subject: [PATCH] add discard_oversize parameter, move optimizer to training subsection --- examples/experiments/onto-joint/defaults.cfg | 3 ++- examples/experiments/ptb-joint-pos-dep/bilstm_tok2vec.cfg | 3 ++- examples/experiments/ptb-joint-pos-dep/defaults.cfg | 3 ++- examples/experiments/tok2vec-ner/charembed_tok2vec.cfg | 3 ++- .../experiments/tok2vec-ner/multihashembed_tok2vec.cfg | 3 ++- spacy/__main__.py | 7 +++---- spacy/cli/__init__.py | 3 +-- spacy/cli/train_from_config.py | 1 - spacy/ml/__init__.py | 1 + 9 files changed, 15 insertions(+), 12 deletions(-) diff --git a/examples/experiments/onto-joint/defaults.cfg b/examples/experiments/onto-joint/defaults.cfg index fbac4ea7d..0fdbc5cf5 100644 --- a/examples/experiments/onto-joint/defaults.cfg +++ b/examples/experiments/onto-joint/defaults.cfg @@ -25,6 +25,7 @@ score_weights = {"las": 0.4, "ents_f": 0.4, "tags_acc": 0.2} # These settings are invalid for the transformer models. init_tok2vec = null vectors = null +discard_oversize = false [training.batch_size] @schedules = "compounding.v1" @@ -32,7 +33,7 @@ start = 1000 stop = 1000 compound = 1.001 -[optimizer] +[training.optimizer] @optimizers = "Adam.v1" beta1 = 0.9 beta2 = 0.999 diff --git a/examples/experiments/ptb-joint-pos-dep/bilstm_tok2vec.cfg b/examples/experiments/ptb-joint-pos-dep/bilstm_tok2vec.cfg index e152fa5e0..fdd4139f8 100644 --- a/examples/experiments/ptb-joint-pos-dep/bilstm_tok2vec.cfg +++ b/examples/experiments/ptb-joint-pos-dep/bilstm_tok2vec.cfg @@ -14,6 +14,7 @@ score_weights = {"las": 0.8, "tags_acc": 0.2} limit = 0 seed = 0 accumulate_gradient = 2 +discard_oversize = false [training.batch_size] @schedules = "compounding.v1" @@ -21,7 +22,7 @@ start = 100 stop = 1000 compound = 1.001 -[optimizer] +[training.optimizer] @optimizers = "Adam.v1" learn_rate = 0.001 beta1 = 0.9 diff --git a/examples/experiments/ptb-joint-pos-dep/defaults.cfg b/examples/experiments/ptb-joint-pos-dep/defaults.cfg index 9a10c45f0..5b369d782 100644 --- a/examples/experiments/ptb-joint-pos-dep/defaults.cfg +++ b/examples/experiments/ptb-joint-pos-dep/defaults.cfg @@ -14,6 +14,7 @@ score_weights = {"las": 0.8, "tags_acc": 0.2} limit = 0 seed = 0 accumulate_gradient = 2 +discard_oversize = false [training.batch_size] @schedules = "compounding.v1" @@ -21,7 +22,7 @@ start = 100 stop = 1000 compound = 1.001 -[optimizer] +[training.optimizer] @optimizers = "Adam.v1" learn_rate = 0.001 beta1 = 0.9 diff --git a/examples/experiments/tok2vec-ner/charembed_tok2vec.cfg b/examples/experiments/tok2vec-ner/charembed_tok2vec.cfg index 796c8670f..8e5c3a276 100644 --- a/examples/experiments/tok2vec-ner/charembed_tok2vec.cfg +++ b/examples/experiments/tok2vec-ner/charembed_tok2vec.cfg @@ -12,8 +12,9 @@ max_length = 0 batch_size = 25 seed = 0 accumulate_gradient = 2 +discard_oversize = false -[optimizer] +[training.optimizer] @optimizers = "Adam.v1" learn_rate = 0.001 beta1 = 0.9 diff --git a/examples/experiments/tok2vec-ner/multihashembed_tok2vec.cfg b/examples/experiments/tok2vec-ner/multihashembed_tok2vec.cfg index 3ac70675b..149b8ea66 100644 --- a/examples/experiments/tok2vec-ner/multihashembed_tok2vec.cfg +++ b/examples/experiments/tok2vec-ner/multihashembed_tok2vec.cfg @@ -11,6 +11,7 @@ gold_preproc = true max_length = 0 seed = 0 accumulate_gradient = 2 +discard_oversize = false [training.batch_size] @schedules = "compounding.v1" @@ -19,7 +20,7 @@ stop = 3000 compound = 1.001 -[optimizer] +[training.optimizer] @optimizers = "Adam.v1" learn_rate = 0.001 beta1 = 0.9 diff --git a/spacy/__main__.py b/spacy/__main__.py index 71ab1a91a..beed3170d 100644 --- a/spacy/__main__.py +++ b/spacy/__main__.py @@ -2,16 +2,15 @@ if __name__ == "__main__": import plac import sys from wasabi import msg - from spacy.cli import download, link, info, package, train, pretrain, convert + from spacy.cli import download, link, info, package, pretrain, convert from spacy.cli import init_model, profile, evaluate, validate, debug_data - from spacy.cli import train_from_config_cli + from spacy.cli import train_cli commands = { "download": download, "link": link, "info": info, - "train": train, - "train-from-config": train_from_config_cli, + "train": train_cli, "pretrain": pretrain, "debug-data": debug_data, "evaluate": evaluate, diff --git a/spacy/cli/__init__.py b/spacy/cli/__init__.py index 5f83b26c1..2ffbe2d0c 100644 --- a/spacy/cli/__init__.py +++ b/spacy/cli/__init__.py @@ -4,8 +4,7 @@ from .download import download # noqa: F401 from .info import info # noqa: F401 from .package import package # noqa: F401 from .profile import profile # noqa: F401 -from .train import train # noqa: F401 -from .train_from_config import train_from_config_cli # noqa: F401 +from .train_from_config import train_cli # noqa: F401 from .pretrain import pretrain # noqa: F401 from .debug_data import debug_data # noqa: F401 from .evaluate import evaluate # noqa: F401 diff --git a/spacy/cli/train_from_config.py b/spacy/cli/train_from_config.py index 852f456de..9cdc3bf2f 100644 --- a/spacy/cli/train_from_config.py +++ b/spacy/cli/train_from_config.py @@ -374,7 +374,6 @@ def train_while_improving( # Stop if we've exhausted our max steps (if specified) if max_steps and (step * accumulate_gradient) >= max_steps: break - step += 1 def subdivide_batch(batch, accumulate_gradient): diff --git a/spacy/ml/__init__.py b/spacy/ml/__init__.py index e69de29bb..cf4f59d6c 100644 --- a/spacy/ml/__init__.py +++ b/spacy/ml/__init__.py @@ -0,0 +1 @@ +from .models import * \ No newline at end of file