#!/bin/bash

if [ $# -ne 4 ]; then
    echo "$0 <log_file> <exp_name> <preprocessed_data_path/> <mlm_steps>"
    echo "  require 4 args, given $#"
    echo "  mlm_steps: en,pt,en-pt  or   en,pt   or  pt"
    exit;
fi

log_file=$1
exp_name=$2
data_path=$3
mlm_steps=$4

dump_path=`dirname ${log_file}`/dumps/


epoch_size=10000
max_epoch=1000
bsize=64

emb_dim=512
n_layers=6
n_heads=4
dropout=0.3
attn_dropout=0.0

#optimizer="adam,lr=0.0001"  # default
optimizer="adam,lr=0.0002"

echo "-----------------------------------------------"
echo "  Started `date`"
echo "-----------------------------------------------"
echo "  Pretraining : ${mlm_steps}"
echo "  Data path   : ${data_path}"

# queue-freegpu.pl is for BUT SGE cluster only
queue-freegpu.pl --config conf/queue.conf --gpu 2 ${log_file} \
                 python train.py \
    --exp_name ${exp_name} \
    --data_path ${data_path} \
    --dump_path ${dump_path} \
    --lgs en-pt \
    --clm_steps "" \
    --mlm_steps "${mlm_steps}" \
    --encoder_only true \
    --emb_dim ${emb_dim} \
    --n_layers ${n_layers} \
    --n_heads ${n_heads} \
    --local_rank 0 \
    --dropout ${dropout} \
    --attention_dropout ${attn_dropout} \
    --epoch_size ${epoch_size} \
    --max_epoch ${max_epoch} \
    --batch_size ${bsize} \
    --optimizer ${optimizer}

echo "-----------------------------------------------"
echo "  Done    `date`"
echo "-----------------------------------------------"
