spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

Error when using spacy CLI train command

Open xiapoy opened this issue 9 years ago • 9 comments

I tried to train a tagger and parser using the spacy CLI train command:

python -m spacy train <lang> . <lang>-train.json --no-ner

The script breaks at the end of the training; here is the output:

Itn.	N weight	N feats	UAS	NER F.	Tag %	Token %
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1455/1455 [01:11<00:00, 20.37it/s]
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/ubuntu/spaCy/spacy/__main__.py", line 133, in <module>
    plac.Interpreter.call(CLI)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 1142, in call
    print(out)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 914, in __exit__
    self.close(exctype, exc, tb)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 952, in close
    self._interpreter.throw(exctype, exc, tb)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 964, in _make_interpreter
    arglist = yield task
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 1139, in call
    raise_(task.etype, task.exc, task.tb)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 380, in _wrap
    for value in genobj:
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 95, in gen_exc
    raise_(etype, exc, tb)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 966, in _make_interpreter
    cmd, result = self.parser.consume(arglist)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/home/ubuntu/spaCy/spacy/__main__.py", line 95, in train
    not no_parser, not no_ner, parser_L1)
  File "/home/ubuntu/spaCy/spacy/cli/train.py", line 39, in train
    entity_cfg, n_iter)
  File "/home/ubuntu/spaCy/spacy/cli/train.py", line 68, in train_model
    **dev_scores.scores)
AttributeError: 'list' object has no attribute 'scores'

My current environment is:

    Info about spaCy

    Python version     2.7.12         
    Platform           Linux-4.4.0 Ubuntu-16.04
    spaCy version      1.8.0          
    Installed models                   
    Location           /home/ubuntu/spaCy/spacy

xiapoy avatar Apr 23 '17 13:04 xiapoy

Thanks for the report – fixing!

(Looks like the main problem here is the dev scores not being passed to print_progress correctly when using the command without dev_data. So yeah, it failed on... printing 😉 Sorry about that.)

ines avatar Apr 23 '17 13:04 ines

Thanks for your quick answer. I re-compiled spaCy from source and tried to re-train the models, but got a new error. Here is the output:

Itn.	N weight	N feats	UAS	NER F.	Tag %	Token %
100%|██████████████████████████████████████████████████████████████████████| 1455/1455 [01:09<00:00, 23.41it/s]
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/ubuntu/spaCy/spacy/__main__.py", line 133, in <module>
    plac.Interpreter.call(CLI)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 1142, in call
    print(out)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 914, in __exit__
    self.close(exctype, exc, tb)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 952, in close
    self._interpreter.throw(exctype, exc, tb)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 964, in _make_interpreter
    arglist = yield task
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 1139, in call
    raise_(task.etype, task.exc, task.tb)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 380, in _wrap
    for value in genobj:
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 95, in gen_exc
    raise_(etype, exc, tb)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_ext.py", line 966, in _make_interpreter
    cmd, result = self.parser.consume(arglist)
  File "/home/ubuntu/spaCy/.env/local/lib/python2.7/site-packages/plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/home/ubuntu/spaCy/spacy/__main__.py", line 95, in train
    not no_parser, not no_ner, parser_L1)
  File "/home/ubuntu/spaCy/spacy/cli/train.py", line 39, in train
    entity_cfg, n_iter)
  File "/home/ubuntu/spaCy/spacy/cli/train.py", line 68, in train_model
    **dev_scores)
  File "/home/ubuntu/spaCy/spacy/cli/train.py", line 101, in print_progress
    print(tpl.format(itn, nr_weight, nr_active_feat, **scores))
KeyError: u'uas'

I am using the same environment. Did I miss something?

xiapoy avatar Apr 23 '17 20:04 xiapoy

Sorry this was my fault. Try again? Just made another tweak.

honnibal avatar Apr 23 '17 20:04 honnibal

@honnibal I tried again with the last spaCy version (1.8.1) and got the same error.

xiapoy avatar Apr 24 '17 19:04 xiapoy

@naileakim Sorry, I think we didn't v1.8.1 still contains the same error (didn't test properly), but it should be fixed on master.

ines avatar Apr 25 '17 08:04 ines

I confirm you that I still got that error while using latest master updates. I could finally succeed to train the model by adding the dev_data.

xiapoy avatar Apr 26 '17 20:04 xiapoy

This is finally fixed in v2.0.0 alpha!

ines avatar Jun 05 '17 23:06 ines

how about 1.9.0, @ines ?

ctthang avatar Jul 31 '17 13:07 ctthang

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar May 08 '18 18:05 lock[bot]