summaryrefslogtreecommitdiff
path: root/experiments/narrow_depth_sweep.sh
blob: 3e4e6b2a78333a99f0cd2e7b3c074af480fc7add (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# Narrow residual-network depth sweep for credit-assignment scaling.
#
# Usage:
#   bash experiments/narrow_depth_sweep.sh \
#     <gpu> "<depths>" "<modes>" <width> <seed> <epochs> <prefix> [pert_mode] [n_dirs]
#
# Example:
#   bash experiments/narrow_depth_sweep.sh 5 "30 60" "bp dfa sdil" 64 0 5 pilot_jac
set -eu

cd "$(dirname "$0")/.."
PY=/home/yurenh2/miniconda3/envs/ep_pascal/bin/python3
GPU="${1:?GPU index required}"
DEPTHS="${2:-30 60}"
MODES="${3:-bp dfa sdil}"
WIDTH="${4:-64}"
SEED="${5:-0}"
EPOCHS="${6:-5}"
PREFIX="${7:-narrow}"
PERT_MODE="${8:-layerwise}"
N_DIRS="${9:-8}"

export CUDA_VISIBLE_DEVICES="$GPU"
export OMP_NUM_THREADS=2
mkdir -p results logs/narrow

run_one() {
  local depth="$1"
  local mode="$2"
  local eta=0.05
  local tag="${PREFIX}_cifar10_${mode}_w${WIDTH}_d${depth}_s${SEED}"
  local result="results/${tag}.json"
  local log="logs/narrow/${tag}.log"
  if [[ -f "$result" ]]; then
    echo "skip $tag (result exists)"
    return
  fi
  if [[ "$mode" == sdil ]]; then
    eta=0.02
  fi
  echo ">>> $tag $(date --iso-8601=seconds) gpu=$GPU eta=$eta"
  "$PY" experiments/run.py \
    --mode "$mode" --dataset cifar10 --depth "$depth" --width "$WIDTH" \
    --act tanh --residual 1 --epochs "$EPOCHS" --seed "$SEED" \
    --eta "$eta" --eta_A 0.02 --pert_ndirs "$N_DIRS" --pert_mode "$PERT_MODE" \
    --log_every 500 --probe_bs 256 --tag "$tag" --outdir results \
    > "$log" 2>&1
  grep -h DONE "$log"
}

for depth in $DEPTHS; do
  for mode in $MODES; do
    run_one "$depth" "$mode"
  done
done