tensorflow2.0——tensorboard画图使用

进入项目路径

 

输入“ tensorboard --logdir 文件夹名 ”  监听该文件夹

 代码中编写将数据写入本地:

   1.  标量数据写入:

    

   2.  图片数据写入:

    

      结果展示:

      

    多张图片显示(直接传入多张图片):

      

    多张图片(将多张图片转化为1张图片)数据写入:

        

     结果展示:

      

import tensorflow as tf
import datetime


#   tensorboard文件处理
current_time = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')                #   当前时间
# print('当前时间:',current_time)
log_dir = 'tb_data/logs/' + current_time                                        #   以当前时间作为log文件名
summary_writer = tf.summary.create_file_writer(log_dir)                         #   创建log文件

#   加载手写数字数据
mnist = tf.keras.datasets.mnist
(train_x, train_y), (test_x, test_y) = mnist.load_data()
x = tf.cast(train_x,tf.float32) /255
print(x.shape)
x = tf.reshape(x[0:15],[-1,28,28,1])


#   将数据写入log文件
with summary_writer .as_default():
    tf.summary.scalar('loss',float(2),step=0)                       #   加载标量数据
    tf.summary.scalar('acc', float(80), step=0)
    tf.summary.image('imag', x,max_outputs=25, step=0)              #   加载图片数据
原文地址:https://www.cnblogs.com/cxhzy/p/13536506.html