windows环境下使用python中tensorflow的tensorboard功能无法创建指定路径的问题

An error occurred while assigning a directory path to tensorboard:

tensorflow.python.framework.errors_impl.InvalidArgumentError: Failed to create a directory: F:\tensorflow\catdog\logs/CatsDogsCNN64*2-1602584133; Invalid argument

code:

1 NAME = f'CatsDogsCNN64*2-{int(time.time())}'
2 logD = "F:\\tensorflow\\catdog\\logs\\{}".format(NAME)
3 tsrBd = TensorBoard(log_dir=logD)
4 print(logD)
model.fit(X, y, batch_size=32, epochs=10, validation_split=0.1, callbacks=[tsrBd])

 

 I've tried a bunch of methods to create the path string including the r-literal, the double back slash '\\' and os.path.join().

None of those worked. See the issue: https://github.com/tensorflow/tensorboard/issues/2023

But the solution in this issue does not work for me.

The solution I found is that you should not provide a dynamic path when assigning log_dir to tensorboard but rather use a fixed name (string), such as:

logD = os.path.join("logs", "c&d")

So this is bascially the same as creating manually a directory in windows.

Hopefully google can fix this bug for Windows in the future. It is extremely frustrating and annoying to deal with this kind of problem because you have to pour so much energy in debugging and gain little from it.

 

posted @ 2020-10-13 20:26  略略略——  阅读(753)  评论(0编辑  收藏  举报