LSTM is extremely slow ( 2 hours )
See original GitHub issueHi. I’m trianing an LSTM network that takes 2 hours to train 1000 training data with only 2000 iterations. Why is it so very slow?
// learns if string is like a date
// get training data
const trainingData = [
{"input":"33 minutes ago","output":"yes"},
{"input":"20 hours ago","output":"yes"},
{"input":"May 7 at 13:42 AM","output":"yes"},
{"input":"Feb 21 at 8:43 AM","output":"yes"},
{"input":"Jul 22, 2012 ","output":"yes"},
{"input":"Apr 14, 2018 ","output":"yes"}
// 1000 total...
]
const network = new brain.recurrent.LSTM();
// create configuration for training
const config = {
iterations: 2000,
log: true,
logPeriod: 200,
layers: [10],
log(detail) {
console.log(detail);
}
};
network.train(trainingData, config);
const output = network.run('Apr 6, 2014');
console.log(`Is like a date: ${(output == 'yes') ? 'YES' : 'NO' }`);
Issue Analytics
- State:
- Created 4 years ago
- Comments:11
Top Results From Across the Web
deep learning - Why does my LSTM take so much time to train?
The main problem is that training is awfully slow : each iteration of training takes about half a day. Since training usually takes...
Read more >Why is my LSTM in tensorflow learning so slowly and badly?
It's not only faster but it produces mostly meaningful words. This produces gibberish only.
Read more >Why is my LSTM network taking 3 hours to train on a single ...
I have been training a LSTM network that contains 5000 samples of numerical data (each containing 100 time-steps). I am perplexed as to...
Read more >Why is my GPU slower than CPU when training LSTM/RNN ...
1 Answer. This is mainly due to the sequential computation in the LSTM layer. Remember that LSTM requires sequential input to calculate the...
Read more >Very slow training on GPU for LSTM NLP multiclass ...
The training step of LSTM NN consumes 15+ min just for the first epoch. It seems I made a mistake somewhere. def train_model(model,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I didn’t pay more attention to your trainingSet in my previous answer, but I see that you are trying to train your network with dates in the form of strings. I suggest you to take a different approach by normalizing your data:
Maybe try to see what the similarities are in your data and use them in your trainingSet as inputs instead of a literal string Example: hasSpaces, hasNumber, hasStrings, hasCommas, hasYear, … (I suggest you add more of those)
Make a short script before, reviewing all your data by checking if it meets the above criteria. (e.g. if hasSpaces, then your first input value should be 1, and so on)
Then fill your trainingSet like that:
And when you want to use
run
, go through to same processThe training takes too long i.e. somewhere around 14 hours or even more… My data set is having different output for different input strings…
Is there a way i can reduce my training time? Although i am storing the trained results in JSON and using that while retrieving the output…
Using Node with brain.js version 2.0.0-alpha.11
const trainingData = [ {“input”:“How are you”,“output”:“very well”}, {“input”:“How have you been”,“output”:“very well”}, {“input”:“welcome to new york”,“output”:“thanks”}, {“input”:“welcome to our city”,“output”:“thanks”}, {“input”:“welcome to usa”,“output”:“thanks”}, {“input”:“Lets catchup today”,“output”:“ofcourse”}, {“input”:“Lets meet today”,“output”:“ofcourse”} … many more… //large data set with different responses for different scenarios… ]
const network = new brain.recurrent.LSTM();
// create configuration for training const config = { iterations: 10000, log: true, };
network.train(trainingData, config);