How do I solve reset_default_graph() error with tensorflow?

184 Views Asked by At

I am trying to train a model in VS code and have written this code (a part of it):

import tensorflow as tf
import tflearn'
....
tf.reset_default_graph()

net = tflearn.input_data(shape=[None, len(trening[0])]) 
net = tflearn.fully_connected(net, 8) 
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(output[0]), activation="softmax") 
net = tflearn.regression(net)

modell = tflearn.DNN(net)

try: 
    modell.load("modell.tflearn")
except:
    modell.fit(trening, output, n_epoch=1000, batch_size=8, show_metric=True) 
    modell.save("modell.tflearn")
...

output: raise RuntimeError('Attempted to use a closed Session.') RuntimeError: Attempted to use a closed Session.

I don't understand what I am doing wrong, can someone help?

1

There are 1 best solutions below

0
AudioBubble On

You can remove try and except block and mention only the below lines from except block without try and except, this should work.

modell.fit(trening, output, n_epoch=1000, batch_size=8, show_metric=True) 
modell.save("modell.tflearn")