Slowness when training multiple Convolutional Networks within a for loop #20183
Unanswered
muriloasouza
asked this question in
Q&A
Replies: 1 comment
|
The timings shown suggest accumulation across many model fits, rather than one Conv1D model gradually becoming slower: the later example is epoch 13 of a different horizon/initialization after the process has already created many models. Three things are worth separating:
A cleanup block should be placed inside the initialization loop: history_dict = {k: list(v) for k, v in history.history.items()}
del history, model, checkpoint, early_stopping
keras.backend.clear_session()
gc.collect()Also move Before changing the model, profile one early and one late epoch with checkpointing disabled. If batch computation stays constant but the epoch boundary grows, the cause is callbacks/I/O. If individual training steps grow, isolate runs in subprocesses and compare fixed input shapes to changing ones. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I am training several Keras models inside a for loop. Check the following code:
When the train starts, each epoch takes around
280ms. But as trains go on, each epoch lasts around 3s. I have tried to solve this problem using clear_session(), but nothing changed. I also have tried to delete the model when it finishes the .fit and also use gc.collect(), but none worked.This increase in training time only happens if i use the
Conv1Dnetwork. If i use theMLP, the training time is constant at around90msand does not increase. What is happening here? What is causing this increase in training time for theConv1D? Any ideas how to fix this?Here some examples:
All reactions