簡體   English   中英

Plot 自定義數據與 Tensorboard

[英]Plot custom data with Tensorboard

我有一個 RL 算法的個人實現,它每 x 個時間步生成性能指標。

該指標只是一個標量,所以我有一個標量數組,我想將它們顯示為一個簡單的圖形,例如:

在此處輸入圖像描述

我想像上面的例子一樣在張量板上實時顯示它。

提前致謝

如果你真的想使用 tensorboard,你可以開始查看tensorflow 網站和這個關於 tensorboard 的數據營教程

使用 tensorflow 您可以使用summary.scalar到 plot 您的自定義數據(作為示例),不需要特定格式,因為摘要會處理這一點,唯一的條件是data必須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 .

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM