Graph

import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
graph = tf.get_default_graph()
graph.get_operations()
[]
a = tf.constant(2, name = "one")
operations = graph.get_operations()

operations

b = tf.constant(2, name = "two")
b
<tf.Tensor 'two:0' shape=() dtype=int32>
operations
[<tf.Operation 'one' type=Const>]
c = tf.add(a, b, name = "three")
c
<tf.Tensor 'three:0' shape=() dtype=int32>
operations
[<tf.Operation 'one' type=Const>,
 <tf.Operation 'one_1' type=Const>,
 <tf.Operation 'three' type=Add>,
 <tf.Operation 'one_2' type=Const>]
session = tf.Session()
print(session.run(c))
4
c
<tf.Tensor 'three:0' shape=() dtype=int32>
for op in operations:
    print(op.name)
one
session.close()