You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_pywrap_file_io.RecursivelyCreateDir(compat.path_to_bytes(path)) tensorflow.python.framework.errors_impl.FailedPreconditionError: /tmp/tmp-kerasmodelnblehs96 is not a directory
#92
Open
furyhawk opened this issue
May 28, 2021
· 2 comments
Traceback (most recent call last):
File "init_ac_agent.py", line 42, in
main()
File "init_ac_agent.py", line 38, in main
new_agent.serialize(outf)
File "/home/furyhawk/deep_learning_and_the_game_of_go/code/dlgo/rl/ac.py", line 100, in serialize
kerasutil.save_model_to_hdf5_group(self.model, h5file['model'])
File "/home/furyhawk/deep_learning_and_the_game_of_go/code/dlgo/kerasutil.py", line 17, in save_model_to_hdf5_group
save_model(model, tempfname)
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/save.py", line 150, in save_model
saved_model_save.save(model, filepath, overwrite, include_optimizer,
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/saved_model/save.py", line 89, in save
saved_nodes, node_paths = save_lib.save_and_return_nodes(
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/saved_model/save.py", line 1110, in save_and_return_nodes
utils_impl.get_or_create_variables_dir(export_dir)
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/saved_model/utils_impl.py", line 220, in get_or_create_variables_dir
file_io.recursive_create_dir(variables_dir)
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/lib/io/file_io.py", line 499, in recursive_create_dir
recursive_create_dir_v2(dirname)
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/lib/io/file_io.py", line 514, in recursive_create_dir_v2
_pywrap_file_io.RecursivelyCreateDir(compat.path_to_bytes(path))
tensorflow.python.framework.errors_impl.FailedPreconditionError: /tmp/tmp-kerasmodelnblehs96 is not a directory
The text was updated successfully, but these errors were encountered:
This is happening because H5 is no longer the default file type for keras.save_model in TensorFlow 2.0. The new default is to save in TensorFlow SavedModel format, and SavedModel uses a directory as a root, not a file. To update the code from the book to work with recent versions of Keras/TensorFlow, edit kerasutil.py and in the save_model_to_hdf5_group function, in the call to tempfile.mkstemp specify the suffix like so: tempfile.mkstemp(prefix='tmp-kerasmodel', suffix='.h5'). The suffix prompts the save_model function to use H5 instead of SavedModel. Alternately you can specify save_model(model, tempfname, save_format='h5') It only needs to be done in the save_model_to_hdf5_group function, loading will work fine without it.
Running in both windows and WSL
python3 init_ac_agent.py --board-size 9 ac_v1.hdf5
produce the following error message
Traceback (most recent call last):
File "init_ac_agent.py", line 42, in
main()
File "init_ac_agent.py", line 38, in main
new_agent.serialize(outf)
File "/home/furyhawk/deep_learning_and_the_game_of_go/code/dlgo/rl/ac.py", line 100, in serialize
kerasutil.save_model_to_hdf5_group(self.model, h5file['model'])
File "/home/furyhawk/deep_learning_and_the_game_of_go/code/dlgo/kerasutil.py", line 17, in save_model_to_hdf5_group
save_model(model, tempfname)
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/save.py", line 150, in save_model
saved_model_save.save(model, filepath, overwrite, include_optimizer,
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/saved_model/save.py", line 89, in save
saved_nodes, node_paths = save_lib.save_and_return_nodes(
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/saved_model/save.py", line 1110, in save_and_return_nodes
utils_impl.get_or_create_variables_dir(export_dir)
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/saved_model/utils_impl.py", line 220, in get_or_create_variables_dir
file_io.recursive_create_dir(variables_dir)
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/lib/io/file_io.py", line 499, in recursive_create_dir
recursive_create_dir_v2(dirname)
File "/home/furyhawk/.local/lib/python3.8/site-packages/tensorflow/python/lib/io/file_io.py", line 514, in recursive_create_dir_v2
_pywrap_file_io.RecursivelyCreateDir(compat.path_to_bytes(path))
tensorflow.python.framework.errors_impl.FailedPreconditionError: /tmp/tmp-kerasmodelnblehs96 is not a directory
The text was updated successfully, but these errors were encountered: