Hello every one, I am getting a stack error while testing new unique data to the model I have trained. The error says " RuntimeError: Attempted to use a closed Session.". I am not much expert with tensorflow. Some may help me to figure out why?. Thanks! @alextp @MicaelCarvalho @jfsantos
print ("Now, Testing the unlabel data and writing the results")
YPredByNNForUnlabeledData = sess.run(tf.argmax(yPredbyNN,1),feed_dict={X: testing_features})
print (YPredByNNForUnlabeledData)
for i in xrange (len(YPredByNNForUnlabeledData)):
if YPredByNNForUnlabeledData[i] == 0:
ClassLabelFinal.append('classical')
else:
ClassLabelFinal.append('blues')
cwd = os.getcwd()
Test_dataset_path = ("/Users/MA/Desktop/BluesTest")%cwd
Test_dataset, Total_Instances = load_instances(Test_dataset_path)
timestamps = load_timestamps(Test_dataset)
write_results(timestamps, ClassLabelFinal, 'Result.csv')
RuntimeError Traceback (most recent call last)
1 print ("Now, Testing the unlabel data and writing the results")
----> 2 YPredByNNForUnlabeledData = sess.run(tf.argmax(yPredbyNN,1),feed_dict={X: testing_features})
3 print (YPredByNNForUnlabeledData)
4 for i in xrange (len(YPredByNNForUnlabeledData)):
5
C:\Users\MA\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
764 try:
765 result = self._run(None, fetches, feed_dict, options_ptr,
--> 766 run_metadata_ptr)
767 if run_metadata:
768 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
C:\Users\MA\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
900 # Check session.
901 if self._closed:
--> 902 raise RuntimeError('Attempted to use a closed Session.')
903 if self.graph.version == 0:
904 raise RuntimeError('The Session graph is empty. Add operations to the '
RuntimeError: Attempted to use a closed Session.
This type of question is better asked at StackOverflow, the GitHub page is mostly used for bug reports, and this is clearly not the case. Also, when bug reporting, please fill the template (it is the default text on the "New issue" screen, you just have to fill the gaps). Enclosing your codes/outputs with the code tags also helps, so we can read the logs without much effort.
Your problem is on line 2, when you run sess.run
. But sess
seems to be an invalid/closed session. Either you're calling this outside a with tf.Session() as session:
block or you have closed your session before running sess.run
.
Most helpful comment
This type of question is better asked at StackOverflow, the GitHub page is mostly used for bug reports, and this is clearly not the case. Also, when bug reporting, please fill the template (it is the default text on the "New issue" screen, you just have to fill the gaps). Enclosing your codes/outputs with the code tags also helps, so we can read the logs without much effort.
Your problem is on line 2, when you run
sess.run
. Butsess
seems to be an invalid/closed session. Either you're calling this outside awith tf.Session() as session:
block or you have closed your session before runningsess.run
.