简体   繁体   English

Spacy权限错误13

[英]Spacy Permission Error 13

I am getting Permission error 13 when trying to save a trained model in spacy. 尝试以随机方式保存经过训练的模型时,出现权限错误13。 I have tried changing the directory as well. 我也尝试过更改目录。 I am trying to reproduce this example given here , to train custom entities in spacy`s named entity recognizer. 我试图重现此处给出的示例,以在spacy的命名实体识别器中训练自定义实体。

import random 

TRAIN_DATA = [
     ("Uber blew through $1 million a week", {'entities': [(0, 4, 'ORG')]}),
     ("Google rebrands its business apps", {'entities': [(0, 6, "ORG")]})
]

nlp = spacy.blank('en')
optimizer = nlp.begin_training()
for i in range(20):
    random.shuffle(TRAIN_DATA)
    for text, annotations in TRAIN_DATA:
        nlp.update([text], [annotations], sgd=optimizer)
nlp.to_disk('/model')

Here is the error I am getting 这是我得到的错误

PermissionError                           Traceback (most recent call last)
<ipython-input-5-115363841730> in <module>()
     14     for text, annotations in TRAIN_DATA:
     15         nlp.update([text], [annotations], sgd=optimizer)
---> 16 nlp.to_disk('/model')

~/anaconda2/envs/py35/lib/python3.5/site-packages/spacy/language.py in to_disk(self, path, disable)
    596             serializers[name] = lambda p, proc=proc: proc.to_disk(p, vocab=False)
    597         serializers['vocab'] = lambda p: self.vocab.to_disk(p)
--> 598         util.to_disk(path, serializers, {p: False for p in disable})
    599 
    600     def from_disk(self, path, disable=tuple()):

~/anaconda2/envs/py35/lib/python3.5/site-packages/spacy/util.py in to_disk(path, writers, exclude)
    508     path = ensure_path(path)
    509     if not path.exists():
--> 510         path.mkdir()
    511     for key, writer in writers.items():
    512         if key not in exclude:

~/anaconda2/envs/py35/lib/python3.5/pathlib.py in mkdir(self, mode, parents, exist_ok)
   1214             self._raise_closed()
   1215         try:
-> 1216             self._accessor.mkdir(self, mode)
   1217         except FileNotFoundError:
   1218             if not parents or self.parent == self:

~/anaconda2/envs/py35/lib/python3.5/pathlib.py in wrapped(pathobj, *args)
    369         @functools.wraps(strfunc)
    370         def wrapped(pathobj, *args):
--> 371             return strfunc(str(pathobj), *args)
    372         return staticmethod(wrapped)
    373 

PermissionError: [Errno 13] Permission denied: '/model'

我认为可能是因为您使用/model的路径被视为绝对路径,所以要么退出用户可写的/model目录,要么尝试使用./model这样的路径作为相对路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM