I am a noob and i need help. If I try this simple try/except statement and if I havn't a pretrained model to load, I always get an error. But if I have already a model to load it works. It does also work when I remove the try/except and train my model every time I run my programm. Thanks.
try:
model.load("model.tflearn")
except:
model.fit(training, output, n_epoch=300, batch_size=8, show_metric=True)
model.save("model.tflearn")
Traceback (most recent call last):
File "C:/Users/Eric/PycharmProjects/ai_chatbot/nlp.py", line 82, in <module>
model.fit(training, output, n_epoch=300, batch_size=8, show_metric=True)
File "C:\Users\Eric\anaconda3\envs\chatbot\lib\site-packages\tflearn\models\dnn.py", line 206, in fit
callbacks=callbacks)
File "C:\Users\Eric\anaconda3\envs\chatbot\lib\site-packages\tflearn\helpers\trainer.py", line 344, in fit
show_metric)
File "C:\Users\Eric\anaconda3\envs\chatbot\lib\site-packages\tflearn\helpers\trainer.py", line 826, in _train
tflearn.is_training(True, session=self.session)
File "C:\Users\Eric\anaconda3\envs\chatbot\lib\site-packages\tflearn\config.py", line 95, in is_training
tf.get_collection('is_training_ops')[0].eval(session=session)
File "C:\Users\Eric\anaconda3\envs\chatbot\lib\site-packages\tensorflow\python\framework\ops.py", line 921, in eval
return _eval_using_default_session(self, feed_dict, self.graph, session)
File "C:\Users\Eric\anaconda3\envs\chatbot\lib\site-packages\tensorflow\python\framework\ops.py", line 5512, in _eval_using_default_session
return session.run(tensors, feed_dict)
File "C:\Users\Eric\anaconda3\envs\chatbot\lib\site-packages\tensorflow\python\client\session.py", line 968, in run
run_metadata_ptr)
File "C:\Users\Eric\anaconda3\envs\chatbot\lib\site-packages\tensorflow\python\client\session.py", line 1114, in _run
raise RuntimeError('Attempted to use a closed Session.')
RuntimeError: Attempted to use a closed Session.
PS: I use anaconda with a venv and tflearn for my model
I'm not sure how tflearn works but I think your error comes from this line:
model.fit(training, output, n_epoch=300, batch_size=8, show_metric=Trwhich is outsidetry:block.