Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Attempted to use a closed Session. #8379

Closed
Techlucy opened this issue Mar 14, 2017 · 1 comment
Closed

RuntimeError: Attempted to use a closed Session. #8379

Techlucy opened this issue Mar 14, 2017 · 1 comment

Comments

@Techlucy
Copy link

Techlucy commented Mar 14, 2017

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')


Now, Testing the unlabel data and writing the results

RuntimeError Traceback (most recent call last)
in ()
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.

@MicaelCarvalho
Copy link
Contributor

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.

@drpngx drpngx added stat:awaiting response Status - Awaiting response from author and removed stat:awaiting response Status - Awaiting response from author labels Mar 14, 2017
@drpngx drpngx closed this as completed Mar 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants