In Chapter 10 ‘NLP’ i ran into an issue: model takes too long to train - 42 min for 1 epoch.
Here is the code from book:
get_imdb = partial(get_text_files, folders=['train', 'test', 'unsup'])
dls_lm = DataBlock(
).dataloaders(path, path=path, bs=128, seq_len=80)
learn = language_model_learner(
dls_lm, AWD_LSTM, drop_mult=0.3,
Later in the chapter we are fine-tuning the model after unfreezing it for 10 epochs, which i cannot afford:
How do i make it train for less time? I figured, i could limit the number of entries to
dls_lm. This would affect accuracy of the model but im ok with it. But i cannot figure out how to do it.
Or mb there is another way to train for less time?
No real ways to make it go faster, I’m afraid. LSTM, RNN, and NLP model architectures in general take longer (and more GPU-mem) to train.
Not sure what you are trying to do here, but if you are not bothered by the accuracy, and just want to go through the steps, you could just train for fewer epochs? For example, after unfreezing just do
learn.fit_one_cycle(1, 2e-3) instead of
10 epochs. It’s mainly to show you what are the training metrics and changes that you should watch out for anyways, so you could also just look at the output in the provided notebooks, if you cannot actually go through all the training steps on your machine.
Thanks for the answer!
That’s what i eventually did
But the question still bothers me: how do i limit number of entries in dls? Is there an elegant way to do it?
Hi Yorick Hope your are having a wonderful day!
You could use callbacks save each epoch to a drive such as Gdrive on Google Colab and reload the saved output.
If you use Google Colab and you have code to operate the mouse to stop the session from timing out, you can do this while you sleep.