Exercise

Training the model with validation

Here you will learn how to train the neural machine translator model with a validation step.

You are provided with the nmt model that you created in the last chapter. Furthermore, you will train the model on a English and French sentences obtained from the Udacity Github Repo. You are provided with training English text (tr_en) and French text (tf_fr) as well as validation English text (v_en) and French text (v_fr) from the previous exercise.

Training the model takes a bit of time so your code will take a little longer to run.

Instructions

100 XP
  • Create validation data by transforming v_en and v_fr using sents2seqs function.
  • Get a properly transformed batch of inputs and outputs using the sents2seqs function.
  • Use the inputs (en_x) and outputs (de_y) to train the nmt on a single batch.
  • Use v_en_x and v_de_y along with valid_size as batch_size to evaluate the nmt model and obtain the validation accuracy.