如何使用 Keras 的 Tensorboard 回调? [英] How do I use the Tensorboard callback of Keras?

查看:39
本文介绍了如何使用 Keras 的 Tensorboard 回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 Keras 构建了一个神经网络.我会通过 Tensorboard 可视化它的数据,因此我使用了:

I have built a neural network with Keras. I would visualize its data by Tensorboard, therefore I have utilized:

keras.callbacks.TensorBoard(log_dir='/Graph', histogram_freq=0,
                            write_graph=True, write_images=True)

keras.io 中所述.当我运行回调时,我得到 ,但我的文件夹Graph"中没有任何文件.我使用这个回调的方式有问题吗?

as explained in keras.io. When I run the callback I get <keras.callbacks.TensorBoard at 0x7f9abb3898>, but I don't get any file in my folder "Graph". Is there something wrong in how I have used this callback?

推荐答案

keras.callbacks.TensorBoard(log_dir='./Graph', histogram_freq=0,  
          write_graph=True, write_images=True)

这一行创建了一个回调 Tensorboard 对象,您应该捕获该对象并将其提供给模型的 fit 函数.

This line creates a Callback Tensorboard object, you should capture that object and give it to the fit function of your model.

tbCallBack = keras.callbacks.TensorBoard(log_dir='./Graph', histogram_freq=0, write_graph=True, write_images=True)
...
model.fit(...inputs and parameters..., callbacks=[tbCallBack])

通过这种方式,您将回调对象提供给了函数.它将在训练期间运行,并将输出可与张量板一起使用的文件.

This way you gave your callback object to the function. It will be run during the training and will output files that can be used with tensorboard.

如果要可视化训练期间创建的文件,请在终端中运行

If you want to visualize the files created during training, run in your terminal

tensorboard --logdir path_to_current_dir/Graph 

希望这有帮助!

这篇关于如何使用 Keras 的 Tensorboard 回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆