allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.73k stars 2.24k forks source link

Introduction tutorial is broken #300

Closed schmmd closed 5 years ago

schmmd commented 7 years ago

From: http://allennlp.org/tutorials/training-and-evaluating

python -m allennlp.run train tutorials/getting_started/simple_tagger.json --serialization_dir /tmp/tutorials/getting_started

Traceback (most recent call last):
  File "/Users/michaels/hack/allenai/allennlp/allennlp/common/params.py", line 78, in pop
    value = self.params.pop(key)
KeyError: 'optimizer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/michaels/miniconda3/envs/allennlp/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/michaels/miniconda3/envs/allennlp/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/michaels/hack/allenai/allennlp/allennlp/run.py", line 13, in <module>
    main(prog="python -m allennlp.run")
  File "/Users/michaels/hack/allenai/allennlp/allennlp/commands/__init__.py", line 27, in main
    args.func(args)
  File "/Users/michaels/hack/allenai/allennlp/allennlp/commands/train.py", line 97, in _train_model_from_args
    train_model_from_file(args.param_path, args.serialization_dir)
  File "/Users/michaels/hack/allenai/allennlp/allennlp/commands/train.py", line 116, in train_model_from_file
    return train_model(params, serialization_dir)
  File "/Users/michaels/hack/allenai/allennlp/allennlp/commands/train.py", line 182, in train_model
    trainer_params)
  File "/Users/michaels/hack/allenai/allennlp/allennlp/training/trainer.py", line 368, in from_params
    optimizer = Optimizer.from_params(parameters, params.pop("optimizer"))
  File "/Users/michaels/hack/allenai/allennlp/allennlp/common/params.py", line 80, in pop
    raise ConfigurationError("key \"{}\" is required at location \"{}\"".format(key, self.history))
allennlp.common.checks.ConfigurationError: 'key "optimizer" is required at location "trainer."'
schmmd commented 7 years ago

I was running out of date code.

lyriccoder commented 5 years ago

Hi @schmmd. Could you please help me? I cannot train the model too. I have the latest version of the code, but I am using the pretrained model which is available on this site:

ner-model-2018.12.18.tar.gz

I get the same error: Traceback (most recent call last): File ".../Research.py", line 372, in validation_iterator=None) File "...\venv\lib\site-packages\allennlp\training\trainer.py", line 687, in from_params optimizer = Optimizer.from_params(parameters, params.pop("optimizer")) File "...\venv\lib\site-packages\allennlp\common\params.py", line 248, in pop raise ConfigurationError("key \"{}\" is required at location \"{}\"".format(key, self.history)) allennlp.common.checks.ConfigurationError: 'key "optimizer" is required at location ""'

I used the config which is in the ner-model-2018.12.18.tar.gz archive.

Also I used the config which is available here: https://github.com/allenai/allennlp/blob/master/training_config/ner.jsonnet

But I still get the error. Could you please tell me how have you fixed the problem? I can't train the model

schmmd commented 5 years ago

@lyriccoder can you open a new issue with a full reproduction? It would be good to know the exact command you are running to retrain a model, as well as the version of AllenNLP you are using. If you're getting an error, please include the full stacktrace.