TestRandomization / code /case2 /train_all.sh
harryzhang1018's picture
Add reproduction code and README (part 2)
c399dd1 verified
Raw History Blame Contribute Delete
1.07 kB
#!/usr/bin/env bash
# Train the 24 Case 2 PPO policies: 3 training-noise configs (nonoise, release, robust) x 8 seeds.
# Seeds 1001-1004: design policies (exploration, goal set A). Seeds 2001-2004: held-out policies (goal set B).
# Each run is single-threaded and seeded (about 50 min on one core of a Ryzen 7 5800X).
# Usage: ./train_all.sh [workers=10] [out_root=policies_retrained] (python: $PYTHON, default python)
# The released policies in policies/ are not overwritten. Each run writes <out_root>/<config>_s<seed>/
# (ckpt_1..4.zip at 0.5/1.0/1.5/2.0 M steps, train_meta.json, episode_returns.npy); ckpt_4.zip is the policy.
set -euo pipefail
cd "$(dirname "$0")"
WORKERS=${1:-10}
OUT=${2:-policies_retrained}
PY=${PYTHON:-python}
mkdir -p "$OUT/logs"
for s in 1001 1002 1003 1004 2001 2002 2003 2004; do
for cfg in nonoise release robust; do echo "$cfg $s"; done
done | xargs -P "$WORKERS" -L 1 bash -c 'OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 '"$PY"' train_ppo.py --config $0 --seed $1 --out '"$OUT"'/$0_s$1 > '"$OUT"'/logs/$0_s$1.log 2>&1 && echo done $0 $1'