File size: 2,338 Bytes
3bbd5dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# Run phase-5 jobs back to back on one GPU.
#
#   phase5_queue.sh GPU [--after PID] JOB [JOB ...]
#
# JOB is NAME:SEED (train the default arms, then evaluate), eval:NAME:SEED
# (evaluate only), or teach:NAME:SEED (train only the two backbone-target arms
# into the same checkpoint directory, then evaluate every arm found there).
# --after PID waits for an already running process before starting.
set -u
cd "$(dirname "$0")/.."
set -a; [ -f .env ] && . ./.env; set +a
export CUDA_DEVICE_ORDER=PCI_BUS_ID
export CUDA_VISIBLE_DEVICES=$1; shift
if [ "$1" = "--after" ]; then tail --pid="$2" -f /dev/null; shift 2; fi

P3=/data/cs769_mtp/scratch/data/phase3
P4=/data/cs769_mtp/scratch/data/phase4_fertility
C3=/data/cs769_mtp/scratch/checkpoints/phase3
C4=/data/cs769_mtp/scratch/checkpoints/phase4_fertility
CK=/data/cs769_mtp/scratch/checkpoints/phase5
LOGS=/data/cs769_mtp/scratch/logs/phase5
OUT=results/phase5_dependent
mkdir -p "$LOGS" "$OUT"

paths() {  # sets DATA (prefix of _train_ids.npy / _heldout.jsonl) and NTP for a condition and seed
  case $1 in
    Devanagari) DATA=$P3/L4; NTP=$C3/L4_seed$2/ntp.pt ;;
    ITRANS)     DATA=$P3/L2; NTP=$C3/L2_seed$2/ntp.pt ;;
    English)    DATA=$P3/E1; NTP=$C3/E1_seed$2/ntp.pt ;;
    IAST)       DATA=$P4/IAST; NTP=$C4/IAST_seed$2/ntp.pt ;;
    ISO)        DATA=$P4/ISO; NTP=$C4/ISO_seed$2/ntp.pt ;;
    *) echo "unknown condition $1"; exit 1 ;;
  esac
}

for job in "$@"; do
  only_eval=0; arms=(); tag=""
  case $job in
    eval:*) only_eval=1; job=${job#eval:} ;;
    teach:*) arms=(--arms independent_teacher,dependent_teacher); tag="_teacher"; job=${job#teach:} ;;
  esac
  name=${job%%:*}; seed=${job##*:}
  paths "$name" "$seed"
  if [ $only_eval = 0 ]; then
    .venv/bin/python scripts/phase5_dependent_train.py --name "$name" --train-ids "${DATA}_train_ids.npy" --seed "$seed" "${arms[@]}" \
      --out "$OUT/train_${name}_seed${seed}${tag}.json" > "$LOGS/train_${name}_seed${seed}${tag}.log" 2>&1
  fi
  ntp_arg=(); [ -f "$NTP" ] && ntp_arg=(--ntp-ckpt "$NTP")
  .venv/bin/python scripts/phase5_dependent_eval.py --name "$name" --ckpt-dir "$CK/${name}_seed${seed}" \
    --train-ids "${DATA}_train_ids.npy" --heldout "${DATA}_heldout.jsonl" "${ntp_arg[@]}" \
    --out "$OUT/eval_${name}_seed${seed}.json" > "$LOGS/eval_${name}_seed${seed}.log" 2>&1
done