Relative Content

Tag Archive for tensorflowmachine-learningkerasdeep-learninglstm

Training model in loop(new model in each iteration), training time increases after nearly 600 iterations of loop

I am training a LSTM model and validating it using “leave one out” cross validation. I have 11520 samples, so I have to train a new model 11520 times. I am using loop for each split of data given by ‘LeaveOneOut” function of scikit learn, inside that loop I am initializing a new model, train it, predict test set and then using “keras.backend.clear_session()” to clear old model, after that using “tf.compat.v1.reset_default_graph()” to reset graph, then using “gc.collect()” to collect grabage. Initially models are trained in nearly 6-7 seconds but after training 600 models training time increases to 25-50 seconds. Here is my code..