1. Learn
  2. /
  3. Courses
  4. /
  5. Recurrent Neural Networks (RNN) for Language Modeling in Python

Exercise

Stacking RNN layers

Deep RNN models can have tens to hundreds of layers in order to achieve state-of-the-art results.

In this exercise, you will get a glimpse of how to create deep RNN models by stacking layers of LSTM cells one after the other.

To do this, you will set the return_sequences argument to True on the firsts two LSTM layers and to False on the last LSTM layer.

To create models with even more layers, you can keep adding them one after the other or create a function that uses the .add() method inside a loop to add many layers with few lines of code.

Instructions

100 XP
  • Import the LSTM layer.
  • Return the sequences in the first two layers and don't return the sequences in the last LSTM layer.
  • Load the pre-trained weights.
  • Print the loss and accuracy obtained.