summaryrefslogtreecommitdiff
path: root/experiments/rain_ep_upfront_calibration_r5.sh
blob: 7b997dfe2f29446d49f205af0cdf23e164630482 (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
57
58
59
60
61
62
#!/usr/bin/env bash
set -euo pipefail

ROOT=/home/yurenh2/sdil
AUTHOR=/scratch/yurenh2/energy-based-learning
PYTHON=/scratch/yurenh2/venvs/burstccn/bin/python
PROFILE="$ROOT/results/physical_bias/p0_state_dependence.json"
OUT="${RAIN_EP_OUT:-$ROOT/results/ep_bias/centered_r5_upfront}"
mkdir -p "$OUT"
cd "$AUTHOR"

run_cell() {
  local gpu=$1
  local probes=$2
  local mode=$3
  local tag=$4
  local predictor_kind=$5
  CUBLAS_WORKSPACE_CONFIG=:4096:8 CUDA_VISIBLE_DEVICES="$gpu" "$PYTHON" \
    "$ROOT/experiments/rain_ep_bias_train.py" \
    --author-root "$AUTHOR" --device cuda \
    --adapter dillavou --network-protocol comparative32 \
    --beta-policy centered --beta-value 0.25 \
    --mode "$mode" --bias-ratio 1 \
    --dillavou-profile-json "$PROFILE" --predictor-rate 1 \
    --predictor-kind "$predictor_kind" \
    --dillavou-calibration-steps "$probes" --neutral-cadence 0 \
    --epochs 1 --schedule-epochs 100 \
    --train-limit 10000 --test-limit 2000 --batch-size 128 \
    --training-iterations 15 --inference-iterations 60 \
    --evaluation-split train_holdout --data-seed 6200 \
    --seed 1988 --beta-seed 7100 --deterministic \
    --output "$OUT/$tag.json" > "$OUT/$tag.log" 2>&1
}

probe_budgets=(2 4 8 16)
gpu=0
for probes in "${probe_budgets[@]}"; do
  run_cell "$gpu" "$probes" constant "probes_${probes}_intercept" nlms &
  gpu=$((gpu + 1))
  run_cell "$gpu" "$probes" innovation "probes_${probes}_sdil" \
    "${SDIL_PREDICTOR_KIND:-nlms}" &
  gpu=$((gpu + 1))
done
wait

"$PYTHON" - "$OUT" <<'PY'
import json
from pathlib import Path
import sys

root = Path(sys.argv[1])
by_budget = {}
for path in sorted(root.glob("probes_*.json")):
    _, probes, method = path.stem.split("_", 2)
    report = json.loads(path.read_text())
    by_budget.setdefault(probes, {})[method] = report["final"]["test_accuracy"]
for probes, values in by_budget.items():
    values["sdil_minus_intercept"] = values["sdil"] - values["intercept"]
summary = {"by_upfront_probe_budget": by_budget}
(root / "summary.json").write_text(json.dumps(summary, indent=2) + "\n")
print(json.dumps(summary, indent=2))
PY