From the course: Deep Learning with Python and Keras: Build a Model for Sentiment Analysis
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Training an LSTM network
From the course: Deep Learning with Python and Keras: Build a Model for Sentiment Analysis
Training an LSTM network
- [Instructor] In this movie, instead of using a simple recurrent neural network, let's use a recurrent neural network with LSTM cells, long short-term memory cells, and see whether we can get better results on our data. Once again, I set an embedding dimensionality of 128. I then instantiate our sequential LSTM model. And the first layer of the LSTM model is an embedding layer as before. Input dimensionality, vocab size. Output dimensionality, embedding dimension. That is 128. Now, I fear that my simple RNN was overfitting on the training data, which is why it didn't do that well on our test data. This is why I've added a spatial dropout layer right after my embedding layer. Now, I use the spatial dropout 1D, which behaves similar to a dropout layer, but it drops entire one-dimensional feature maps instead of individual elements. After the spatial dropout, I specify the LSTM layer of the model. The number of units in…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.