在 TensorFlow 中显示图形的图像? [英] Display image of graph in TensorFlow?

查看:29
本文介绍了在 TensorFlow 中显示图形的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个简单的脚本来计算 1、2、5 的黄金比例.有没有办法通过实际图形结构的张量流(可能在 matplotlibnetworkx 的帮助下)实际产生视觉效果?tensorflow 的文档与因子图非常相似,所以我想知道:

I wrote a simple script to calculate the golden ratio from 1,2,5. Is there a way to actually produce a visual through tensorflow (possibly with the aid of matplotlib or networkx) of the actual graph structure? The doc of tensorflow is pretty similar to a factor graph so I was wondering:

如何通过tensorflow生成图结构的图像?

在下面的这个例子中,将 C_1, C_2, C_3 作为单独的节点,然后 C_1 将具有 tf.sqrt操作之后是将它们组合在一起的操作.也许图结构(节点,边)可以导入networkx?我看到 tensor 对象有一个 graph 属性,但我还没有找到如何将它实际用于成像目的.

In this example below, it would be C_1, C_2, C_3 as individual nodes, and then C_1 would have the tf.sqrt operation followed by the operation that brings them together. Maybe the graph structure (nodes,edges) can be imported into networkx? I see that the tensor objects have a graph attribute but I haven't found out how to actually use this for imaging purposes.

#!/usr/bin/python

import tensorflow as tf
C_1 = tf.constant(5.0)
C_2 = tf.constant(1.0)
C_3 = tf.constant(2.0)

golden_ratio = (tf.sqrt(C_1) + C_2)/C_3

sess = tf.Session()
print sess.run(golden_ratio) #1.61803
sess.close()

推荐答案

您可以使用 张量板.您需要编辑代码以输出图形,然后您可以启动 tensorboard 并查看它.请特别参阅 TensorBoard:图形可视化.您创建一个 SummaryWriter 并在其中包含 sess.graph_def.图形定义将输出到日志目录.

You can get an image of the graph using Tensorboard. You need to edit your code to output the graph, and then you can launch tensorboard and see it. See, in particular, TensorBoard: Graph Visualization. You create a SummaryWriter and include the sess.graph_def in it. The graph def will be output to the log directory.

这篇关于在 TensorFlow 中显示图形的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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