The number of nodes available in the current graph keep increasing at every iteration. This seems unintuitive since the session is closed, and all of it's resources should be freed. What is the reason why the previous nodes are still lingering even when creating a new session? Here is my code:
for i in range(3):
var = tf.Variable(0)
sess = tf.Session(config=tf.ConfigProto())
with sess.as_default():
tf.global_variables_initializer().run()
print(len(sess.graph._nodes_by_name.keys()))
sess.close()
It outputs:
5
10
15