2 bling b Bling_B 于 2017.08.28 16:39 提问

Ubuntu16.04系统plot出现permission denied
import numpy as np  
from keras.models import Sequential  
from keras.layers.core import Dense, Activation  
from keras.optimizers import SGD  
from keras.utils import np_utils      
from keras.utils.visualize_util import plot  
def run():  
    model = Sequential()  
    model.add(Dense(4, input_dim=2, init='uniform'))  
    model.add(Activation('relu'))  
    model.add(Dense(2, init='uniform'))  
    model.add(Activation('sigmoid'))  
    sgd = SGD(lr=0.05, decay=1e-6, momentum=0.9, nesterov=True)  
    model.compile(loss='binary_crossentropy', optimizer=sgd, metrics=['accuracy'])  
    plot(model, to_file='model.png')  
if __name__ == '__main__':  
    run()  

错误提示:
Traceback (most recent call last):
File "example2.py", line 21, in
run()

File "example2.py", line 18, in run
plot(model, to_file='model.png')

File "/home/c249/anaconda2/lib/python2.7/site-packages/keras/utils/visualize_util.py", line 64, in plot
dot.write_png(to_file)
File "/home/c249/anaconda2/lib/python2.7/site-packages/pydot.py", line 1811, in
lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))
File "/home/c249/anaconda2/lib/python2.7/site-packages/pydot.py", line 1913, in write
dot_fd.write(self.create(prog, format))
File "/home/c249/anaconda2/lib/python2.7/site-packages/pydot.py", line 1992, in create
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
File "/home/c249/anaconda2/lib/python2.7/subprocess.py", line 390, in __init
_
errread, errwrite)
File "/home/c249/anaconda2/lib/python2.7/subprocess.py", line 1024, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied

1个回答

kongxx
kongxx   2017.08.28 16:47

应该是对当前目录没有写权限吧,代码好像要产生model.png文件呢。

Bling_B
Bling_B 但是还是出现之前的问题
3 个月之前 回复
Bling_B
Bling_B 谢谢回复。我用chmod a+w给当前目录添加了写权限,
3 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片