0
$\begingroup$

I need to run neural network training with different hyper parameters settings like this:

for seed in range(2):
        NN_inst = FeedForwardNN(seed)
        NN_inst.load_data()
        NN_inst.classification_model()
        NN_inst.run_model()

First run everything works. On the second run I get tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value training/Adam/Variable_39 [[{{node training/Adam/Variable_39/read}} = IdentityT=DT_FLOAT, _class=["loc:@training/Adam/Variable_39"], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

It looks like I need to clear tensorflow memory, but

K.clear_session()
tf.reset_default_graph()

do not help. I am using Keras, error is on fit(). What should I do?

$\endgroup$
1
$\begingroup$

I using InteractiveSession() and closing it every time worked

sess = tf.InteractiveSession()
#code here ...
sess.close()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.