Is there a way in Tensorflow to find if a given tf.Session()
is still open? The only way I have found so far is to try to use it, and catch the exception when it is not open.
Check if session._closed is True
sess = tf.Session()
init_op = tf.global_variables_initializer()
sess.run(init_op)
print(sess._closed)
sess.close()
print(sess._closed)
Output
False
True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With