SpaCy 'nlp.to_disk' is not saving to disk

若如初见. 提交于 2021-01-28 12:00:42

问题


I am trying to figure out why my custom SpaCy NER model isn't saving to disk using nlp.to_disk. I am using this condition in my python script:

 # save model to output directory
    if output_dir is not None:
        output_dir = Path(output_dir)
        if not output_dir.exists():
            output_dir.mkdir()
        nlp.to_disk(output_dir)
        print("Saved model to", output_dir)

The output_dir is defined at the top of my script as:

@plac.annotations(
    model=("Model name. Defaults to blank 'en' model.", "option", "m", str),
    output_dir=("Optional output directory", "option", "o", Path),
    n_iter=("Number of training iterations", "option", "n", int),
)

The model runs without any errors and all of the outputs are correct but it doesn't save to disk. I am not sure what I am missing here. Any help is greatly appreciated.


回答1:


Thanks to polm23 for getting me in the right direction!

I was not adding the option with my directory path defined. Here is what needed to be done to run the model and have it saved.

python train_ner.py -m=en -o=path/to/output/directory -n=1000

It was a silly rookie mistake on my part but I am very appreciative of the help.



来源:https://stackoverflow.com/questions/64249976/spacy-nlp-to-disk-is-not-saving-to-disk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!