如何手动创建 tf.Summary()

编程入门 行业动态 更新时间:2024-10-12 10:18:49
本文介绍了如何手动创建 tf.Summary()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我经常想记录 python 变量——而不是 tf 张量.

I often want to log python variables --as opposed to tf tensors.

在文档中它说你可以传递一个 tf.Summary 协议缓冲区,用你自己的数据填充"但没有 tf.Summary 的文档我不知道如何使用它.

In the docs it says that "you can pass a tf.Summary protocol buffer that you populate with your own data" but there is no docs for tf.Summary and i could not figure out how to use it.

有人知道如何以这种方式创建标量摘要吗?

Anyone knows how to create a Scalar summary this way?

推荐答案

你可以在你的 Python 程序中创建一个 tf.Summary 对象并将其写入同一个 tf.summary.FileWriter 对象,它使用 tf.summary.FileWriter 对象获取 TensorFlow 生成的摘要一个 href="https://www.tensorflow/api_docs/python/tf/summary/FileWriter#add_summary" rel="noreferrer">SummaryWriter.add_summary() 方法.

You can create a tf.Summary object in your Python program and write it to the same tf.summary.FileWriter object that takes your TensorFlow-produced summaries using the SummaryWriter.add_summary() method.

tf.Summary 类是一个 Python 协议缓冲区包装器,用于总结协议缓冲区.每个 Summary 都包含一个 tf.Summary.Value 协议缓冲区,每个都有一个标签和一个简单"(浮点标量)值,一个 图像,直方图,或音频片段.例如,您可以从 Python 对象生成一个标量摘要,如下所示:

The tf.Summary class is a Python protocol buffer wrapper for the Summary protocol buffer. Each Summary contains a list of tf.Summary.Value protocol buffers, which each have a tag and a either a "simple" (floating-point scalar) value, an image, a histogram, or an audio snippet. For example, you can generate a scalar summary from a Python object as follows:

writer = tf.train.SummaryWriter(...)
value = 37.0
summary = tf.Summary(value=[
    tf.Summary.Value(tag="summary_tag", simple_value=value), 
])
writer.add_summary(summary)

这篇关于如何手动创建 tf.Summary()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 05:26:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405341.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:tf   Summary

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!