raghakot / keras-vis

Neural network visualization toolkit for keras
https://raghakot.github.io/keras-vis
MIT License
2.98k stars 664 forks source link

OSError: Unable to create file in apply_modifications #68

Closed thiagoburgo closed 7 years ago

thiagoburgo commented 7 years ago

OS: Windows 10 + Anaconda3


Traceback (most recent call last):
  File "D:\Anaconda3\envs\tensorflow\lib\site-packages\vis\utils\utils.py", line 123, in apply_modifications
    model.save(model_path)
  File "D:\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 2506, in save
    save_model(self, filepath, overwrite, include_optimizer)
  File "D:\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py", line 101, in save_model
    f = h5py.File(filepath, 'w')
  File "D:\Anaconda3\envs\tensorflow\lib\site-packages\h5py\_hl\files.py", line 271, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
  File "D:\Anaconda3\envs\tensorflow\lib\site-packages\h5py\_hl\files.py", line 107, in make_fid
    fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (C:\bld\h5py_1497041388779\work\h5py-2.7.0\h5py\_objects.c:2859)
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (C:\bld\h5py_1497041388779\work\h5py-2.7.0\h5py\_objects.c:2817)
  File "h5py\h5f.pyx", line 98, in h5py.h5f.create (C:\bld\h5py_1497041388779\work\h5py-2.7.0\h5py\h5f.c:2303)
OSError: Unable to create file (Unable to open file: name = '/tmp/1_bxtbyh.h5', errno = 2, error message = 'no such file or directory', flags = 13, o_flags = 302)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "keras-CNN-mnist-2.0.py", line 113, in <module>
    keras_mnist_vis.keras_digits_vis(model, X_test, y_test)
  File "D:\Projetos\IA\keras-mnist-workshop\keras_mnist_vis.py", line 18, in keras_digits_vis
    model = utils.apply_modifications(model)
  File "D:\Anaconda3\envs\tensorflow\lib\site-packages\vis\utils\utils.py", line 126, in apply_modifications
    os.remove(model_path)
FileNotFoundError: [WinError 3] O sistema não pode encontrar o caminho especificado: '/tmp/1_bxtbyh.h5'
vabrishami commented 7 years ago

When I want to modify the model, I encounter the same error. I use Windows 7 + Anaconda 3 and updated version of Keras, Theano, and keras-vis. @thiagoburgo Did you find any solution?

ghost commented 7 years ago

Same here :(

raghakot commented 7 years ago

fixed

ghost commented 7 years ago

File "C:\Users\Francisco\Anaconda3\lib\site-packages\vis\utils\utils.py", line 123, in apply_modifications model.save(model_path) File "C:\Users\Francisco\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2553, in save save_model(self, filepath, overwrite, include_optimizer) File "C:\Users\Francisco\Anaconda3\lib\site-packages\keras\models.py", line 102, in save_model with h5py.File(filepath, mode='w') as f: File "C:\Users\Francisco\Anaconda3\lib\site-packages\h5py_hl\files.py", line 271, in init fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) File "C:\Users\Francisco\Anaconda3\lib\site-packages\h5py_hl\files.py", line 107, in make_fid fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl) File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (C:\Minonda\conda-bld\h5py_1490029446037\work\h5py_objects.c:2867) File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (C:\Minonda\conda-bld\h5py_1490029446037\work\h5py_objects.c:2825) File "h5py\h5f.pyx", line 98, in h5py.h5f.create (C:\Minonda\conda-bld\h5py_1490029446037\work\h5py\h5f.c:2307) OSError: Unable to create file (Unable to open file: name = '/tmp/rkp3rbmq.h5', errno = 2, error message = 'no such file or directory', flags = 13, o_flags = 302)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/Francisco/Pruebas/codigos_test/keras_img.py", line 17, in model = utils.apply_modifications(model) File "C:\Users\Francisco\Anaconda3\lib\site-packages\vis\utils\utils.py", line 126, in apply_modifications os.remove(model_path) FileNotFoundError: [WinError 3] El sistema no puede encontrar la ruta especificada: '/tmp/rkp3rbmq.h5'

hbake001 commented 6 years ago

The same thing applies here:

Model loaded.
Traceback (most recent call last):

  File "<ipython-input-2-c0509c104381>", line 1, in <module>
    debugfile('C:/Users/engadmin/.spyder-py3/visualize_framework.py', wdir='C:/Users/engadmin/.spyder-py3')

  File "c:\users\engadmin\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 733, in debugfile
    debugger.run("runfile(%r, args=%r, wdir=%r)" % (filename, args, wdir))

  File "C:\Users\engadmin\Anaconda3\lib\bdb.py", line 431, in run
    exec(cmd, globals, locals)

  File "<string>", line 1, in <module>

  File "c:\users\engadmin\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
    execfile(filename, namespace)

  File "c:\users\engadmin\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "c:/users/engadmin/.spyder-py3/visualize_framework.py", line 47, in <module>
    model = utils.apply_modifications(model)

  File "c:\users\engadmin\anaconda3\lib\site-packages\vis\utils\utils.py", line 126, in apply_modifications
    os.remove(model_path)

FileNotFoundError: [WinError 3] The system cannot find the path specified: '/tmp/ogx5lb2o.h5'
jphdotam commented 6 years ago

This is due to the line: model_path = '/tmp/' + next(tempfile._get_candidate_names()) + '.h5' in 'tensorflow_backend.py', as /tmp/ does not exist on Windows. Easiest thing to do is create a 'tmp' folder in the current working directory and change '/tmp/' in the above line to './tmp/'

Lijiachen1018 commented 6 years ago

Also modify this line in File "lib\site-packages\vis\utils\utils.py", line 123

model_path = './tmp/' + next(tempfile._get_candidate_names()) + '.h5'

dylan-plummer commented 4 years ago

Rather than modifying the keras-vis code itself, I simply added this line before applying any modifcations:

os.makedirs('/tmp/', exist_ok=True)