$29
Description
In this homework, you will practice how to implement neural machine translation (NMT) using Recurrent Neural Network (RNN). You can choose either Long Short-Term Memory (LSTM) or Gated Recurrent Units (GRU) to implement NMT. The goals of this homework are:
• To understand the steps to train/test the model for NMT.
• To understand and implement the RNN architecture.
The English-Czech, English-German, and English-Vietnamese datasets can be found at:
https://nlp.stanford.edu/projects/nmt/ under Preprocessed Data.
Instruction
1. The neural machine translation file NMT.py should contain three functions, train, test, and translate. You can choose any one of the three datasets (English-Czech, English-German, and English-Vietnamese), based on your interests and the data size.
*GPUs may be needed for speeding up the neural network training process in this homework. If you don’t have a valid GPU, you are suggested to use the English-Vietnamese dataset, which is smaller and can save some training time.
2. The train function would train the network with the command “python NMT.py train”. Display the training loss in each iteration of the training function. Save the model in a folder named “model” after finishing the training process.
Fig. 1 The screenshot of the train function (English-to-Vietnamese).
EECE 7398 HW 3
Fall 2021 ST: Advances in Deep Learning Due 11/29/2021
Fig. 2 The screenshot of the test function (English-to-Vietnamese).
3. The test function would test the model with the command “python NMT.py test”, which will
(1) load the testing data and translate the sentences; and (2) calculate the BLEU score (referring to https://www.nltk.org/_modules/nltk/translate/bleu_score.html) with the smoothing method1. Report the average BLEU score, which should be no less than 7% (0.07).
4. The translation function would accept the command “python NMT.py translate”. Given a sentence, the model should be able to translate it into the corresponding language.
Fig. 3 The screenshot of the translation function (English-to-Vietnamese).
Submission
• You need to submit a zip file including:
1. a python file named “NMT.py”;
2. a generated model folder named “model”;
3. two screenshots of the train and test functions.
• The “NMT.py” file should be able to run with the following commands: python NMT.py train
python NMT.py test python NMT.py translate
• The zip file should be named using the following convention:
<Last-Name>_<First-Name>_HW3.zip
Ex. Wayne_Bruce_HW3.zip
EECE 7398 HW 3
Fall 2021
ST: Advances in Deep Learning
Due 11/29/2021
Note:
Don’t put any print function other than showing the results.
Comment your code.
Grading criteria:
◦ The two screenshots of the train and test functions will be checked, and the translate function will be tested by typing a sentence.
◦ The testing accuracy (BLEU score) should be greater than or equal to 7% (0.07) in the end. There will be 1-point deduction for every 0.1% accuracy degradation based on 7%.
◦ Upload the zip file to Canvas before 11:59 PM (EST Time) 11/29/2021. * Sample code can be found at:
https://github.com/chiphuyen/stanford-tensorflow-tutorials/tree/master/assignments/chatbot