✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔

文章目录

TensorBoard 的正确打开方法

折腾了笔者一整天,终于解决,写下此贴避免后人再折腾,希望能够帮到你 ~ 😃

TensorBoard是一个基于浏览器的观察器,可以监视你模型的训练全过程,这里需要注意的是,我们不需要联网就能打开这个观察器,这只是个 本地服务

本文针对 以下两个问题进行了解答

  1. 空文件夹问题

No dashboards are active for the current data set.

Probable causes:
You haven’t written any data to your event files.

TensorBoard can’t find your event files.

If you’re new to using TensorBoard, and want to find out how to add data and set up your event files, check out the README and perhaps the TensorBoard tutorial.

If you think TensorBoard is configured properly, please see the section of the README devoted to missing data problems and consider filing an issue on GitHub.

  1. 打开文件夹语句版本问题

usage: tensorboard [-h] [–helpfull] [–logdir PATH] [–logdir_spec PATH_SPEC]
[–host ADDR] [–bind_all] [–port PORT]
[–purge_orphaned_data BOOL] [–db URI] [–db_import]
[–inspect] [–version_tb] [–tag TAG] [–event_file PATH]
[–path_prefix PATH] [–window_title TEXT]
[–max_reload_threads COUNT] [–reload_interval SECONDS]
[–reload_task TYPE] [–reload_multifile BOOL]
[–reload_multifile_inactive_secs SECONDS]
[–generic_data TYPE]
[–samples_per_plugin SAMPLES_PER_PLUGIN]
{serve,dev} …

tensorboard: error: invalid choice: ‘my_log_dir2’ (choose from ‘serve’, ‘dev’)

tensorboard: error: invalid choice: 'my_log_dir2' (choose from 'serve', 'dev')

Step1. 代码准备

在代码部分,我们需要调用 keras.callbacks.TensorBoard来记录我们的训练日志

在这里,涉及到了一个路径问题,为简化步骤,我这里直接使用了绝对路径举例, r'C:\Users\19334\my_log_dir' 这个绝对路径是可以换的, 你喜欢存在哪个盘就在哪个盘,但是每次训练的结果会有所不同


my_log = r'C:\Users\19334\my_log_dir'

callbacks = [
    keras.callbacks.TensorBoard(
    log_dir = r'C:\Users\19334\my_log_dir',
    histogram_freq = 1,
    embeddings_freq = 1,)]

history = model.fit(x_train, y_train,
                    epochs = 20,
                    batch_size = 128,
                    validation_split = 0.2,
                    callbacks = callbacks)

然后我们开始训练,训练的详细内容请移步《Python 深度学习》刷书笔记 Chapter 7 使用TensorBoard检查监控深度学习模型

Step2. 改变环境

笔者这里用的Anaconda的命令行为例,如果直接输入tensorboard的指令是行不通的,如图

✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔
如果是Anaconda的环境,直接使用 activate 命令来切换装有 tensorflow的环境,如果是使用Windows 的 cmd的同学,需要先配置一下环境变量,这里我直接用 Anaconda的来举例

✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔

; Step3. 再次确认日志文件是否导出成功

正确导出的文件应该如下所示

[En]

The correctly exported file should look like this

✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔
点开里面还有一些 v2文件
✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔
我们的TensorBoard就是借助这些v2文件画图的

如果文件夹为空,会有以下提示(我这里用了一个不存在的文件夹)

No dashboards are active for the current data set.

Probable causes:
You haven’t written any data to your event files.

TensorBoard can’t find your event files.

If you’re new to using TensorBoard, and want to find out how to add data and set up your event files, check out the README and perhaps the TensorBoard tutorial.

If you think TensorBoard is configured properly, please see the section of the README devoted to missing data problems and consider filing an issue on GitHub.

翻译一下(机翻)

当前数据集没有活动的仪表板。
可能的原因:
您尚未将任何数据写入事件文件。

[En]

You have not written any data to the event file.

TensorBoard找不到事件文件。
如果您是使用TensorBoard的新手,并希望了解如何添加数据和设置事件文件,请查看README,或者TensorBoard教程。
如果您认为TensorBoard配置正确,请参阅README中关于丢失数据问题的部分,并考虑在GitHub上提交问题。

✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔
可能原因主要有 以下两个:
  1. 如前所述, 日志没有导出成功
  2. 打开路径错了

注:Crtl + C退出此页面

; Step4. 使用tensorboard –logdir ” ” 打开文件

注意:一定要使用 tensorboard --logdir "abc" 打开文件

笔者原来的书里面使用 tensorboard --logdir = my_log_dir2打开文件的,但是现在改版了就不适用了,我们要使用 tensorboard --logdir "abc"打开文件, abc是文件夹名(只需打开你输出的那个日志就行了,不需要具体到那个v2文件)

用以前的句子打开的话,会出现 tensorboard: error: invalid choice: 'my_log_dir2' (choose from 'serve', 'dev')

✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔

Step5. 打开网页

根据命令行的提示,我们打开浏览器,像打开网址一样输入 http://localhost:6006/就行

这里特意尝试了一下,用 单引号打开是不行的

✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔
注:如果还是不行,试一下用其他的浏览器(例如 Chome ),避免用IE,笔者用的 Microsoft Edge ,实测在这个版本下是没问题的

; 最终打开结果

✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔
✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔
希望能帮到你~

写在最后

女士们先生们,你们已经看到了这一点。如果对你有用,请用手指给博主点赞。8、您的支持是作者创作的最大动力!

[En]

Ladies and gentlemen, you have seen this. If it is useful to you, please use your fingers to give a like to the blogger. 8, your support for the author’s greatest creative motivation!

<(^-^)>
几乎没有什么才华和学识。如果有任何错误,请改正。

[En]

There is little talent and learning. If there are any mistakes, please correct them.

这篇文章只供同志们学习和交流,不作任何商业用途。如涉及版权问题,请尽快与作者联系。

[En]

This article is only for comrades’ study and communication, not for any commercial use. If copyright issues are involved, please contact the author as soon as possible.

Original: https://blog.csdn.net/LeungSr/article/details/120800763
Author: FeverTwice
Title: ✔✔✔ TensorBoard 的正确打开方法(含错误解决方法,超详细) ✔✔✔

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/496124/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球