问题
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