Filenotfound错误Jupyter-系统找不到指定的路径

时间:2018-11-01 20:19:06

标签: python python-3.x jupyter-notebook jupyter

我正面临以下错误声明

    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

0 个答案:

没有答案