获取所有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)