我试图通过保存在单独的子目录中来在TensorBoard中创建多个图形,类似于here中所述。
但是我似乎在回调中遇到错误-我不确定为什么会出错。
回调:
tensorboard = TensorBoard(log_dir=f"./logs/MODEL", histogram_freq=1,
write_grads=True)
错误:
Traceback (most recent call last):
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\IPython\core\interactiveshell.py", line 2963, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-7fb3ff8a6fa3>", line 46, in <module>
validation_split=0.2, callbacks=[tensorboard, metrics])
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\keras\engine\training.py", line 1657, in fit
validation_steps=validation_steps)
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\keras\engine\training.py", line 1145, in _fit_loop
callbacks.set_model(callback_model)
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\keras\callbacks.py", line 48, in set_model
callback.set_model(model)
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\keras\callbacks.py", line 710, in set_model
self.sess.graph)
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\tensorflow\python\summary\writer\writer.py", line 336, in __init__
filename_suffix)
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\tensorflow\python\summary\writer\event_file_writer.py", line 67, in __init__
gfile.MakeDirs(self._logdir)
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 368, in recursive_create_dir
pywrap_tensorflow.RecursivelyCreateDir(compat.as_bytes(dirname), status)
File "C:\Users\Ad\AppData\Local\conda\conda\envs\coda\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Failed to create a directory: ./logs/1-LTSM-NODES-32-DENSE-1: 1535276781.0160034; Invalid argument
答案 0 :(得分:3)
我有同样的问题。我将/
更改为\
,并且有效
答案 1 :(得分:1)
这在Windows中对我有用
log_dir="logs\\model\\"
答案 2 :(得分:0)
遇到了同样的问题。 在我的情况下,解决方案是用 Path(来自 pathlib 模块)对象包装路径 - 它修复并规范化所有路径斜线问题(适用于 Windows 和 Linux 构建代理),例如:
from pathlib import Path
training_log_dir_path = Path((os.path.join(getRootDir(), log_dir, 't-', mversion)))
training_log_dir = str(training_log_dir_path)