summaryrefslogtreecommitdiff
path: root/experiments/ep_depth2_sweep.sh
blob: fa2937b693d7c7ede36cb5bb6a08f72ed53794aa (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
#!/usr/bin/env bash
# Exact-architecture comparison using the authors' canonical two-hidden-layer
# EP protocol: 784-500-500-10, 60 epochs, batch size 20, 150 free steps,
# 6 nudged steps, beta 1, and layer rates [0.4, 0.1, 0.01].
#
# BP/DFA/SDIL use the identical forward architecture, first 50k MNIST
# training examples, and 60 epochs, while retaining their native feedforward
# preprocessing and dynamics.
# Usage: ep_depth2_sweep.sh <gpu> "<methods>" "<seeds>" [prefix]
set -eu

cd "$(dirname "$0")/.."
PY=/home/yurenh2/miniconda3/envs/ep_pascal/bin/python3
GPU="${1:?GPU index required}"
METHODS="${2:-ep}"
SEEDS="${3:-0}"
PREFIX="${4:-ep_depth2_v1}"

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

for seed in $SEEDS; do
  for method in $METHODS; do
    tag="${PREFIX}_mnist_${method}_w500_d2_s${seed}"
    result="results/${tag}.json"
    log="logs/baselines/${tag}.log"
    if [[ -f "$result" ]]; then
      echo "skip $tag (result exists)"
      continue
    fi
    echo ">>> $tag $(date --iso-8601=seconds) gpu=$GPU"
    if [[ "$method" == "ep" ]]; then
      "$PY" experiments/baseline_run.py \
        --method ep --dataset mnist --depth 2 --width 500 --epochs 60 \
        --batch_size 20 --train_examples 50000 --ep_persistent 1 \
        --seed "$seed" --tag "$tag" --outdir results > "$log" 2>&1
    else
      "$PY" experiments/run.py \
        --mode "$method" --dataset mnist --depth 2 --width 500 \
        --epochs 60 --batch_size 128 --train_examples 50000 \
        --eta 0.05 --eta_A 0.02 --eta_P 0.002 --momentum 0.9 \
        --pert_every 4 --pert_ndirs 16 --pert_mode simultaneous \
        --nuis_rho 0 --residual 0 --act tanh --seed "$seed" \
        --tag "$tag" --outdir results > "$log" 2>&1
    fi
    grep -h DONE "$log"
  done
done