I would like to train some different models with model.fit() parallel in one python application. The used models dont have necessary something in common, they are started in one application at different times.
First I start one model.fit() with no problems in a seperate thread then the main thread. If I now want to start a second model.fit(), I get the following error message:
Exception in thread Thread-1:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Node 'hidden_1/BiasAdd': Unknown input node 'hidden_1/MatMul'
They are both getting started from a method by the same lines of code:
start_learn(self:)
tf_session = K.get_session() # this creates a new session since one doesn't exist already.
tf_graph = tf.get_default_graph()
keras_learn_thread.Learn(learning_data, model, self.env_cont, tf_session, tf_graph)
learning_results.start()
Th called class/method looks like this:
def run(self):
tf_session = self.tf_session # take that from __init__()
tf_graph = self.tf_graph # take that from __init__()
with tf_session.as_default():
with tf_graph.as_default():
self.learn(self.learning_data, self.model, self.env_cont)
# now my learn method where model.fit() is located is being started
I think I somehow have to assign a new tf_session and a new tf_graph for each single thread. But I am not quite sure about that. I would be glad about every short idea, since I am sitting on this for too long now.
Thanks