summaryrefslogtreecommitdiff
path: root/experiments/depth_sweep.sh
blob: f7c4112a45c4932b7ff6a0eaf51263668f76dfe4 (plain)
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
#!/usr/bin/env bash
# Locate the regime where DFA fails and SDIL survives: deep, UNNORMALISED tanh
# MLPs. DFA's random feedback loses gradient alignment with depth; SDIL learns
# the apical pathway per-layer by node perturbation, so alignment should hold.
# Usage: bash depth_sweep.sh "<datasets>" "<depths>" "<seeds>" <epochs> <tag_prefix>
set -u
cd "$(dirname "$0")/.."
PY=/home/yurenh2/miniconda3/envs/ep_pascal/bin/python3
export OMP_NUM_THREADS=2
DATASETS="${1:-mnist fmnist}"
DEPTHS="${2:-3 5 7 10}"
SEEDS="${3:-0}"
EP="${4:-20}"
PFX="${5:-depth}"
OUT=results
LOGS=logs/depth
mkdir -p "$OUT" "$LOGS"
PROG="$LOGS/progress.txt"
echo "=== depth sweep start $(date) datasets=[$DATASETS] depths=[$DEPTHS] seeds=[$SEEDS] ===" >> "$PROG"

run () {
  local tag="$1"; shift
  if [ -f "$OUT/$tag.json" ]; then echo "skip $tag" >> "$PROG"; return; fi
  echo ">>> $tag $(date +%H:%M:%S)" >> "$PROG"
  $PY experiments/run.py --tag "$tag" --outdir "$OUT" "$@" > "$LOGS/$tag.log" 2>&1 \
     && grep -h DONE "$LOGS/$tag.log" >> "$PROG" || echo "FAIL $tag" >> "$PROG"
}

for ds in $DATASETS; do
  for s in $SEEDS; do
    for d in $DEPTHS; do
      for m in bp dfa sdil; do
        run "${PFX}_${ds}_${m}_d${d}_s${s}" --mode $m --dataset $ds --depth $d \
            --width 256 --epochs $EP --seed $s --pert_ndirs 8
      done
    done
  done
done
echo "=== depth sweep done $(date) ===" >> "$PROG"