Skip to content

Instantly share code, notes, and snippets.

@ravi9
Created April 4, 2018 17:41
Show Gist options
  • Save ravi9/c85bf571f624962acfe642991dda6d50 to your computer and use it in GitHub Desktop.
Save ravi9/c85bf571f624962acfe642991dda6d50 to your computer and use it in GitHub Desktop.
Tensorflow NMT benchmark setup
#Git clone NMT
git clone https://github.com/tensorflow/nmt.git
#Download Dataset
cd nmt
nmt/scripts/download_iwslt15.sh /home/ubuntu/nmt_data
#Run training for few steps to get a model, so that we can use it for inference benchmarking.
python -m nmt.nmt \
--src=vi --tgt=en \
--vocab_prefix=/home/ubuntu/nmt_data/vocab \
--train_prefix=/home/ubuntu/nmt_data/train \
--dev_prefix=/home/ubuntu/nmt_data/tst2012 \
--test_prefix=/home/ubuntu/nmt_data/tst2013 \
--out_dir=/home/ubuntu/nmt_model \
--num_train_steps=100 \
--steps_per_stats=100 \
--num_layers=2 \
--num_units=128 \
--dropout=0.2 \
--metrics=bleu \
--batch_size=1024 \
--infer_batch_size=1
#Combine the test files to generate one big test file, so we can benchmark on this one merged file
cat /home/ubuntu/nmt_data/tst2012.vi /home/ubuntu/nmt_data/tst2013.vi > /home/ubuntu/my_infer_file.vi
#Test Inference. Note, infer_batch_size parameter is not working. Need to modify in model/hparams, ex:In /home/ubuntu/nmt_model/hparams
python -m nmt.nmt \
--out_dir=/home/ubuntu/nmt_model \
--inference_input_file=/home/ubuntu/my_infer_file.vi \
--inference_output_file=/home/ubuntu/nmt_model/output_infer \
--infer_batch_size=1024
#To run inference on multiple batch sizes, git clone a script
git clone https://gist.github.com/ravi9/cf62c27d852a261981441b37bf3d2e4f
#Install prereqs: sudo apt install -y moreutils jq
#Edit file paths accordingly.
./nmt_infer_batchsize.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment