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

获取所有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示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持来客网。