tensorflow 获取所有variable或tensor的name示例

yipeiwu_com6年前Python基础

获取所有variable(每个op中可训练的张量)的name:

for variable_name in tf.global_variables():
  print(variable_name)

获取所有tensor(每个op的输出张量)的name:

for tensor_name in tf.contrib.graph_editor.get_tensors(tf.get_default_graph()):
  print(tensor_name)

获取所有op及其输入输出的name:

with tf.Session() as sess:
  for node in sess.graph_def.node:
    print(node)

以上这篇tensorflow 获取所有variable或tensor的name示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

在Python的Django框架中加载模版的方法

为了减少模板加载调用过程及模板本身的冗余代码,Django 提供了一种使用方便且功能强大的 API ,用于从磁盘中加载模板, 要使用此模板加载API,首先你必须将模板的保存位置告诉框架。...

Python人脸识别初探

Python人脸识别初探

本文实例为大家分享了Python人脸识别的具体代码,供大家参考,具体内容如下 1.利用opencv库 sudo apt-get install libopencv-* sudo ap...

python直接访问私有属性的简单方法

实例化对象名._类名__私有属性名 class Flylove: price = 123 def __init__(self): self.__d...

python实现倒计时的示例

复制代码 代码如下:import timecount = 0 a = input('time:') b = a * 60 while (count <...

解决Python运行文件出现out of memory框的问题

解决Python运行文件出现out of memory框的问题

爬虫过程中,发现pycharm变得非常卡,然后出现了这个框: 原本想的是4G内存不够,带不动程序,要加内存条。然后发现图中三个对话框的数字都可以改动,感叹号右边也说please inc...