#python #command-line #spacy
#python #командная строка #spacy
Вопрос:
Я пытаюсь обучить пространственную модель в командной строке с помощью следующего кода:
python -m spacy train en models TRAINDATA.json DEVDATA.json
Произошла эта ошибка: ValueError: Can't read file: modelsmodel0accuracy.json
Я уже создал пустой каталог, но, к сожалению, я получил ту же ошибку.
Трассировка:
(base) C:WINDOWSsystem32>python -m spacy train en models C:WindowsSystem32TRAINDATAconverted.json C:WindowsSystem32TRAINDATAconverted.json
⚠ Output directory is not empty
This can lead to unintended side effects when saving the model. Please use an
empty directory or a different path instead. If the specified output path
doesn't exist, the directory will be created for you.
Training pipeline: ['tagger', 'parser', 'ner']
Starting with blank model 'en'
Counting training words (limit=0)
C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacylanguage.py:639: UserWarning: [W022] Training a new part-of-speech tagger using a model with no lemmatization rules or data. This means that the trained model may not be able to lemmatize correctly. If this is intentional or the language you're using doesn't have lemmatization data, please ignore this warning. If this is surprising, make sure you have the spacy-lookups-data package installed.
**kwargs
C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacylanguage.py:639: UserWarning: [W033] Training a new part-of-speech tagger using a model with no lexeme normalization table. This may degrade the performance of the model to some degree. If this is intentional or the language you're using doesn't have a normalization table, please ignore this warning. If this is surprising, make sure you have the spacy-lookups-data package installed. The languages with lexeme normalization tables are currently: da, de, el, en, id, lb, pt, ru, sr, ta, th.
**kwargs
C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacylanguage.py:639: UserWarning: [W033] Training a new parser or NER using a model with no lexeme normalization table. This may degrade the performance of the model to some degree. If this is intentional or the language you're using doesn't have a normalization table, please ignore this warning. If this is surprising, make sure you have the spacy-lookups-data package installed. The languages with lexeme normalization tables are currently: da, de, el, en, id, lb, pt, ru, sr, ta, th.
**kwargs
Itn Tag Loss Tag % Dep Loss UAS LAS NER Loss NER P NER R NER F Token % CPU WPS
--- --------- -------- --------- ------ ------ --------- ------ ------ ------ ------- -------
⚠ Aborting and saving the final best model. Encountered exception: not enough
values to unpack (expected 2, got 0)
✔ Saved model to output directory
modelsmodel-final
Traceback (most recent call last):
File "C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacyclitrain.py", line 463, in train
scorer = nlp_loaded.evaluate(dev_docs, verbose=verbose)
File "C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacylanguage.py", line 687, in evaluate
docs, golds = zip(*docs_golds)
ValueError: not enough values to unpack (expected 2, got 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacyclitrain.py", line 570, in train
exits=1,
File "C:ProgramDataAnaconda3libsite-packageswasabiprinter.py", line 91, in warn
title, text, style=MESSAGES.WARN, show=show, spaced=spaced, exits=exits
File "C:ProgramDataAnaconda3libsite-packageswasabiprinter.py", line 244, in _get_msg
title, text, color=style, icon=style, show=show, spaced=spaced, exits=exits
File "C:ProgramDataAnaconda3libsite-packageswasabiprinter.py", line 152, in text
sys.exit(exits)
SystemExit: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:ProgramDataAnaconda3librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:ProgramDataAnaconda3librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacy__main__.py", line 33, in <module>
plac.call(commands[command], sys.argv[1:])
File "C:ProgramDataAnaconda3libsite-packagesplac_core.py", line 367, in call
cmd, result = parser.consume(arglist)
File "C:ProgramDataAnaconda3libsite-packagesplac_core.py", line 232, in consume
return cmd, self.func(*(args varargs extraopts), **kwargs)
File "C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacyclitrain.py", line 617, in train
best_model_path = _collate_best_model(final_meta, output_path, best_pipes)
File "C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacyclitrain.py", line 670, in _collate_best_model
bests[component] = _find_best(output_path, component)
File "C:UsersElske nijhofAppDataRoamingPythonPython37site-packagesspacyclitrain.py", line 689, in _find_best
accs = srsly.read_json(epoch_model / "accuracy.json")
File "C:ProgramDataAnaconda3libsite-packagessrsly_json_api.py", line 50, in read_json
file_path = force_path(location)
File "C:ProgramDataAnaconda3libsite-packagessrslyutil.py", line 21, in force_path
raise ValueError("Can't read file: {}".format(location))
ValueError: Can't read file: modelsmodel0accuracy.json
Комментарии:
1. вы проверили
modelsmodel0accuracy.json
, существует ли файл?2. Можете ли вы опубликовать полную трассировку стека?
3. Да, конечно! Только что опубликовал это 🙂
4. Да, я сделал,
modelsmodell0accuracy.json
не существует.
Ответ №1:
Вы можете попробовать явно добавить -t json
, но, похоже, это недавняя ошибка (2020-11-02), поэтому вам, возможно, придется обновить spaCy.