У меня возникает следующее сообщение об ошибке
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/tmp/5pido2dr.h5'
при попытке запустить keras-vis . Блок кода, вызывающий ошибку:
layer_idx = utils.find_layer_idx(model, 'dense_2') #after naming the layers
model.layers[layer_idx].activation = activations.softmax
model = utils.apply_modifications(model)
for class_idx in np.arange(10):
indices = np.where(y_train[:, class_idx] == 1.)[0]
idx = indices[0]
grads = visualize_saliency(model, layer_idx, filter_indices=class_idx,
seed_input=X_train[idx],
backprop_modifier='guided')
f, ax = plt.subplots(1, 2)
ax[0].imshow(X_train[idx][..., 0])
ax[1].imshow(grads, cmap='jet')
savename = "layer_activations" + str(class_idx) + ".png"
f.savefig(savename)
и вывод полной ошибки:
OSError Traceback (most recent call last)
c:\python36\lib\site-packages\vis\utils\utils.py in apply_modifications(model)
122 try:
--> 123 model.save(model_path)
124 return load_model(model_path)
c:\python36\lib\site-packages\keras\engine\network.py in save(self, filepath, overwrite, include_optimizer)
1084 from ..models import save_model
-> 1085 save_model(self, filepath, overwrite, include_optimizer)
1086
c:\python36\lib\site-packages\keras\engine\saving.py in save_model(model, filepath, overwrite, include_optimizer)
104
--> 105 f = h5py.File(filepath, mode='w')
106 opened_new_file = True
c:\python36\lib\site-packages\h5py\_hl\files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, **kwds)
311 fapl = make_fapl(driver, libver, **kwds)
--> 312 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
313
c:\python36\lib\site-packages\h5py\_hl\files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
147 elif mode == 'w':
--> 148 fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
149 elif mode == 'a':
h5py\_objects.pyx in h5py._objects.with_phil.wrapper()
h5py\_objects.pyx in h5py._objects.with_phil.wrapper()
h5py\h5f.pyx in h5py.h5f.create()
OSError: Unable to create file (unable to open file: name = '/tmp/5pido2dr.h5', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 302)
During handling of the above exception, another exception occurred:
FileNotFoundError Traceback (most recent call last)
<ipython-input-20-df7d3b5036c3> in <module>()
1 layer_idx = utils.find_layer_idx(model, 'dense_2') #after naming the layers
2 model.layers[layer_idx].activation = activations.softmax
----> 3 model = utils.apply_modifications(model)
4
5 for class_idx in np.arange(10):
c:\python36\lib\site-packages\vis\utils\utils.py in apply_modifications(model)
** 124 return load_model(model_path)
125 finally:
--> 126 os.remove(model_path)
127
128
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/tmp/5pido2dr.h5'
Существует ошибка ОС , которая является основной причиной. Я не уверен, почему возникает эта ошибка. Имя файла .h5 постоянно меняется. Благодаря должным исследованиям у меня есть предположения, что это может быть проблемой переменной среды и требует переустановки.
Но я не уверен, что правильный метод для отладки. Я использую WIN 10, с Python 3.6.5 и Jupyter 4.4.0