使用Tensorboard绘制自定义数据 [英] Plot custom data with Tensorboard

查看:335
本文介绍了使用Tensorboard绘制自定义数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个RL算法的个人实现,该算法每x个时间步生成一次性能指标。



该指标只是一个标量,所以我想显示为简单图形的标量数组,例如:





我想像上面的示例一样在张量板上实时显示。



预先感谢

解决方案

如果您真的想使用张量板,可以开始查看



也就是说,如果您不打算将tensorflow与您的实现中,我建议您只使用matplotlib,因为该库还使您可以实时绘制数据 https://youtu.be/Ercd-Ip5PfQ?t=444


I have a personal implementation of a RL algorithm that generates performance metrics every x time steps.

That metric is simply a scalar, so I have an array of scalars that I want to display as a simple graph such as:

I want to display it in real time in tensorboard like my above example.

Thanks in advance

解决方案

If you really want to use tensorboard you can start looking at tensorflow site and this datacamp tutorial on tensorboard.

With tensorflow you can use summary.scalar to plot your custom data (as the example), no need for particular format, as the summary is taking care of that, the only condition is that data has to be a real numeric scalar value, convertible to a float32 Tensor.

import tensorflow as tf

import numpy as np

import os
import time

now = time.localtime()
subdir = time.strftime("%d-%b-%Y_%H.%M.%S", now)

summary_dir1 = os.path.join("stackoverflow", subdir, "t1")
summary_writer1 = tf.summary.create_file_writer(summary_dir1)

for cont in range(200):
    with summary_writer1.as_default():
        tf.summary.scalar(name="unify/sin_x", data=np.math.sin(cont) ,step=cont)
        tf.summary.scalar(name="unify/sin_x_2", data=np.math.sin(cont/2), step=cont)
    summary_writer1.flush()

That said, if you are not planning on using tensorflow with your implementation, I would suggest you just use matplotlib as this library also enables you to plot data in real time https://youtu.be/Ercd-Ip5PfQ?t=444.

这篇关于使用Tensorboard绘制自定义数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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