I created an LSTM with Keras API. Now I am facing an issue while I try to test different values in it (for learning rate f.e.). Each time I change my values and define the model new somehow the model takes longer and longer until training start the CPU usage in waiting time is at 100%. Am I doing something wrong so that older learning session effect the new models?
My code is structered as followed, in one file I call a evaluation with different values and many iterations like this:
for i in range(0, 100):
acc = model.create(xtrain, ytrain, hidden_units=hidden_size, batch_size=batch_size, learning_rate=learning_rate, l2_reg=l2_reg)
model is another file. In there I use the passed values to train a new model and pass back the accuracy to find the best batch size etc. Tho code for model creation is something like:
def create(xtrain, ytrain, hidden_units, batch_size, learning_rate, l2_reg):
# defining some layers from input to output
# example: input = Input(shape=(20,)) ...
# creating the model
model = Model(inputs=[input], output=[outputs])
model.compile(optimizer='Adam', loss='binary_crossentropy', metrics=['acc'])
# calling model.fit
es = EarlyStopping(monitor='val_loss', mode='min', patience=4, verbose=1)
model.fit(xtrain, ytrain, epochs=100, batch_size=batch_size, validation_data=(some_xval_data, some_yval_data), callbacks=[es])
## In the end I evaluate the model on unseen data and return the accuracy
loss, acc = model.evaluate(x_testdata, y_testdata, batch_size=batch_size)
return acc
Now everytime the model starts to train the script prints:
Epoch 1/100
On the first evaluation calls the model instantly starts to train and I see the time it takes for each step. But after some time, after the print of "Epoch 1/100" it suddenly starts to take time until the training starts. And the time increases from call to call. While it is waiting for the training to really start I can observe that my CPU usage is at 100% in that time.
So am I doing it wrong in calling the method every time again? Is there some process there older calls of "create" effect newer ones? I just hope that older training is not effecting newer training in my code structure?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)