Skip to content

Commit

Permalink
Add random seed fixing (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostML authored Aug 17, 2021
1 parent 8317ad3 commit 4cdd4c0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
32 changes: 32 additions & 0 deletions tests/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ if [ ${MODE} = "lite_train_infer" ]; then
# Hence, set maximum output length is 16.
sed -i "s/^max_out_len.*/max_out_len: 16/g" configs/transformer.base.yaml
sed -i "s/^max_out_len.*/max_out_len: 16/g" configs/transformer.big.yaml

sed -i "s/^random_seed:.*/random_seed: 128/g" configs/transformer.base.yaml
sed -i "s/^shuffle_batch:.*/shuffle_batch: False/g" configs/transformer.base.yaml
sed -i "s/^shuffle:.*/shuffle: False/g" configs/transformer.base.yaml

sed -i "s/^random_seed:.*/random_seed: 128/g" configs/transformer.big.yaml
sed -i "s/^shuffle_batch:.*/shuffle_batch: False/g" configs/transformer.big.yaml
sed -i "s/^shuffle:.*/shuffle: False/g" configs/transformer.big.yaml
# Data set prepared.
if [ ! -f WMT14.en-de.partial.tar.gz ]; then
wget https://paddlenlp.bj.bcebos.com/datasets/WMT14.en-de.partial.tar.gz
Expand Down Expand Up @@ -51,6 +59,14 @@ elif [ ${MODE} = "whole_infer" ]; then
sed -i "s/^max_out_len.*/max_out_len: 256/g" configs/transformer.base.yaml
sed -i "s/^max_out_len.*/max_out_len: 1024/g" configs/transformer.big.yaml

sed -i "s/^random_seed:.*/random_seed: None/g" configs/transformer.base.yaml
sed -i "s/^shuffle_batch:.*/shuffle_batch: True/g" configs/transformer.base.yaml
sed -i "s/^shuffle:.*/shuffle: True/g" configs/transformer.base.yaml

sed -i "s/^random_seed:.*/random_seed: None/g" configs/transformer.big.yaml
sed -i "s/^shuffle_batch:.*/shuffle_batch: True/g" configs/transformer.big.yaml
sed -i "s/^shuffle:.*/shuffle: True/g" configs/transformer.big.yaml

# Trained transformer base model checkpoint.
# For infer.
if [ ! -f tranformer-base-wmt_ende_bpe.tar.gz ]; then
Expand Down Expand Up @@ -108,6 +124,14 @@ elif [ ${MODE} = "whole_train_infer" ]; then
sed -i "s/^max_out_len.*/max_out_len: 256/g" configs/transformer.base.yaml
sed -i "s/^max_out_len.*/max_out_len: 1024/g" configs/transformer.big.yaml

sed -i "s/^random_seed:.*/random_seed: None/g" configs/transformer.base.yaml
sed -i "s/^shuffle_batch:.*/shuffle_batch: True/g" configs/transformer.base.yaml
sed -i "s/^shuffle:.*/shuffle: True/g" configs/transformer.base.yaml

sed -i "s/^random_seed:.*/random_seed: None/g" configs/transformer.big.yaml
sed -i "s/^shuffle_batch:.*/shuffle_batch: True/g" configs/transformer.big.yaml
sed -i "s/^shuffle:.*/shuffle: True/g" configs/transformer.big.yaml

# Whole data set prepared.
if [ ! -f WMT14.en-de.tar.gz ]; then
wget https://paddlenlp.bj.bcebos.com/datasets/WMT14.en-de.tar.gz
Expand Down Expand Up @@ -153,6 +177,14 @@ else # infer
sed -i "s/^max_out_len.*/max_out_len: 256/g" configs/transformer.base.yaml
sed -i "s/^max_out_len.*/max_out_len: 1024/g" configs/transformer.big.yaml

sed -i "s/^random_seed:.*/random_seed: None/g" configs/transformer.base.yaml
sed -i "s/^shuffle_batch:.*/shuffle_batch: True/g" configs/transformer.base.yaml
sed -i "s/^shuffle:.*/shuffle: True/g" configs/transformer.base.yaml

sed -i "s/^random_seed:.*/random_seed: None/g" configs/transformer.big.yaml
sed -i "s/^shuffle_batch:.*/shuffle_batch: True/g" configs/transformer.big.yaml
sed -i "s/^shuffle:.*/shuffle: True/g" configs/transformer.big.yaml

# Trained transformer base model checkpoint.
if [ ! -f tranformer-base-wmt_ende_bpe.tar.gz ]; then
wget https://paddlenlp.bj.bcebos.com/models/transformers/transformer/tranformer-base-wmt_ende_bpe.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion tests/transformer_base_dygraph_params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python:python3.7
gpu_list:0|0,1
null:null
null:null
--max_iter:lite_train_infer=500
--max_iter:lite_train_infer=100
null:null
null:null
null:null
Expand Down
2 changes: 1 addition & 1 deletion tests/transformer_base_static_params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python:python3.7
gpu_list:0|0,1
null:null
null:null
--max_iter:lite_train_infer=500
--max_iter:lite_train_infer=100
null:null
null:null
null:null
Expand Down
2 changes: 1 addition & 1 deletion tests/transformer_big_dygraph_params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python:python3.7
gpu_list:0|0,1
null:null
null:null
--max_iter:lite_train_infer=500
--max_iter:lite_train_infer=100
null:null
null:null
null:null
Expand Down
2 changes: 1 addition & 1 deletion tests/transformer_big_static_params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python:python3.7
gpu_list:0|0,1
null:null
null:null
--max_iter:lite_train_infer=500
--max_iter:lite_train_infer=100
null:null
null:null
null:null
Expand Down

0 comments on commit 4cdd4c0

Please sign in to comment.