Spacy: Error when using spacy CLI train command

Created on 23 Apr 2017  ยท  9Comments  ยท  Source: explosion/spaCy

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
bug

All 9 comments

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

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?

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

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

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

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.

This is finally fixed in v2.0.0 alpha!

how about 1.9.0, @ines ?

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.

Was this page helpful?
0 / 5 - 0 ratings