Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • VisualDL
  • Wiki
  • example of LogReader

V
VisualDL
  • 项目概览

PaddlePaddle / VisualDL
大约 2 年 前同步成功

通知 89
Star 4655
Fork 642
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 10
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 2
  • Wiki 5
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
V
VisualDL
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 10
    • Issue 10
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 2
    • 合并请求 2
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 5
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板

example of LogReader

最后修改来自于wuzewu 1月 28, 2019
页面历史
from visualdl import LogWriter, LogReader
import random

def write(log_dir):
    log_writer = LogWriter(dir = log_dir, sync_cycle = 5)
    with log_writer.mode("train") as logw:
        # this scalar will record value in mode "train" and has tag "record1"
        scalar_train_1 = logw.scalar("record1")
        # this scalar will record value in mode "train" and has tag "record2"
        scalar_train_2 = logw.scalar("record2")
        
    with log_writer.mode("test") as logw:
        # this scalar will record value in mode "test" and has tag "record1"
        scalar_val_1 = logw.scalar("record1")
        # this scalar will record value in mode "test" and has tag "record2"
        scalar_val_2 = logw.scalar("record2")
        
    for i in range(5):
        # add scalar record with step from 0 to 4
        scalar_train_1.add_record(i, random.random())
        scalar_train_2.add_record(i, random.random())
        scalar_val_1.add_record(i, random.random())
        scalar_val_2.add_record(i, random.random())

def read(log_dir):
    log_reader = LogReader(dir = log_dir)
    
    # get all mode
    modes = log_reader.modes()
    for mode in modes:
        # switch log_reader to appointed mode
        with log_reader.mode(mode) as logr:
            # get all tags, in this case, tag will be record1 or record2
            tags = logr.tags("scalar")
            for tag in tags:
                # each tag consists of many records
                records = logr.scalar(tag = tag).records()
                for step, record in enumerate(records):
                    print("mode %s -- tag %s -- step %d -- val %.2f" % (mode, tag, step, record))
        
if __name__ == "__main__":
    log_dir = "vdl_log"
    write(log_dir)
    read(log_dir)
克隆仓库
  • FAQ
  • Graph 接口定义
  • Home
  • How to use pre commit
  • example of LogReader
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7