I am using a session as an attribute of my class, as in
self.sess = tf.Session()
or
self.sess = tf.InteractiveSession()
The session attribute is used in several functions, e.g.
def get_loss(self, input_data):
return self.sess.run(self.loss, {self.data:input_data})
I know that a session has to be closed at some point. Does this also apply when using the session as an attribute of a class? Do I need a "close_session" function somewhere? If yes, where exactly should I put it in the class?
Regrettably, I couldn't find anything on sessions as class attributes so I am thankful for any advice.