In Tensorflow, get the names of all the Tensors in a graph

前端 未结 10 705
独厮守ぢ
独厮守ぢ 2020-11-27 10:29

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 usi

10条回答
  •  广开言路
    2020-11-27 10:52

    There is a way to do it slightly faster than in Yaroslav's answer by using get_operations. Here is a quick example:

    import tensorflow as tf
    
    a = tf.constant(1.3, name='const_a')
    b = tf.Variable(3.1, name='variable_b')
    c = tf.add(a, b, name='addition')
    d = tf.multiply(c, a, name='multiply')
    
    for op in tf.get_default_graph().get_operations():
        print(str(op.name))
    

提交回复
热议问题