#!/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 "" "" "" 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"