tensor flow

1、get tensor name

import tensorflow as tf
a = tf.constant(1) + tf.constant(2)
with tf.Session() as s:
    print(s.run(a))
    b = tf.get_default_graph()
    print(b.get_tensor_by_name('add:0'))
    c = b.as_graph_def()
    print(c.node) 
    print(list(tensor.name for tensor in c.node))

你可能感兴趣的:(tensor flow)