在 Tensorflow 中,获取图中所有张量的名称 [英] In Tensorflow, get the names of all the Tensors in a graph

查看:49
本文介绍了在 Tensorflow 中,获取图中所有张量的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Tensorflowskflow 创建神经网络;出于某种原因,我想获取给定输入的一些内部张量的值,所以我使用 myClassifier.get_layer_value(input, "tensorName")myClassifier 是一个skflow.estimators.TensorFlowEstimator.

I am creating neural nets with Tensorflow and skflow; for some reason I want to get the values of some inner tensors for a given input, so I am using myClassifier.get_layer_value(input, "tensorName"), myClassifier being a skflow.estimators.TensorFlowEstimator.

然而,我发现很难找到张量名称的正确语法,即使知道它的名称(而且我在操作和张量之间感到困惑),所以我使用张量板来绘制图形并寻找名字.

However, I find it difficult to find the correct syntax of the tensor name, even knowing its name (and I'm getting confused between operation and tensors), so I'm using tensorboard to plot the graph and look for the name.

有没有办法在不使用张量板的情况下枚举图中的所有张量?

Is there a way to enumerate all the tensors in a graph without using tensorboard?

推荐答案

你可以做

[n.name for n in tf.get_default_graph().as_graph_def().node]

此外,如果您在 IPython notebook 中进行原型设计,则可以直接在 notebook 中显示图形,请参阅 Alexander's Deep Dream 中的 show_graph 函数笔记本

Also, if you are prototyping in an IPython notebook, you can show the graph directly in notebook, see show_graph function in Alexander's Deep Dream notebook

这篇关于在 Tensorflow 中,获取图中所有张量的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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