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

Exercise

NMT example

This exercise aims to build on the sneak peek you got of NMT at the beginning of the course. You will continue to translate Portuguese small phrases into English.

Some sample sentences are available on the sentences variable and are printed on the console.

Also, a pre-trained model is available on the model variable and you will use two custom functions to simplify some steps:

  • encode_sequences(): Change texts into sequence of numerical indexes and pad them.
  • translate_many(): Uses the pre-trained model to translate a list of sentences from Portuguese into English. Later you will code this function yourself.

For more details on the functions, use help(). The package pandas is loaded as pd.

Instructions

100 XP
  • Use the encode_sequences() function to pre-process the texts and save the results in the X variable.
  • Translate the sentences using the translate_many() function by passing X as a parameter.
  • Create a pd.DataFrame() with the original and translated lists as columns.
  • Print the data frame.