every blog every motto: You will never know unless you try
0. Preface
Nonsense about the problems encountered by tensorboard : It was clear before, I don't know why I got a convulsion today.
1. Text
Part of the code is as follows
tensorboard_dir = os.path.join('../', 'user_data', 'code2_output', 'tensorboard')
if not os.path.exists(tensorboard_dir):
os.makedirs((tensorboard_dir))
# 回调函数
callbacks = [
TensorBoard(log_dir=tensorboard_dir),
ModelCheckpoint(output_model_file, save_best_only=True, save_freq='epoch'), # 保存模型频率
ReduceLROnPlateau(factor=0.5, patience=3), # 学效率下降
EarlyStopping(min_delta=1e-3, patience=10) # 早停
]
The error is as follows:
tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a directory: ../user_data\code2_output\tensorboard\train\plugins\profile\2021-02-06_21-57-28; No such file or directory
Solution
- Manually create and save the tensorboard folder
- The folder uses logs instead of my code above, the following code
- The folders are connected with os.path.join, as in the code above
- Directory folder uses "\" instead of "/"
tensorboard_dir = os.path.join('../', 'user_data', 'code2_output', 'logs')
Description
I used the fourth method above to solve the problem. The
following code tests are OK
tensorboard_dir = os.path.join('..\\user_data\\code2_output\\tensorboard')
tensorboard_dir = os.path.join(r'..\user_data\code2_output\tensorboard')
tensorboard_dir = os.path.join('..\\', 'user_data', 'code2_output', 'tensorboard')
references
[1] https://stackoom.com/question/3xL0g/%E5%A6%82%E4%BD%95%E4%B8%BA%E6%88%91%E7%9A%84%E9%A1%B9%E7%9B%AE%E5%88%9B%E5%BB%BATensorboard
[2] https://github.com/ibab/tensorflow-wavenet/issues/255
[3] https://stackoverflow.com/questions/49043393/tensorflow-python-framework-errors-impl-notfounderror-failed-to-create-a-direct
[4] https://blog.csdn.net/tz_zs/article/details/76566002