File size: 1,816 Bytes
42c0d23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# scripts/run_spurious.sh
#
# Outcome-C variant: inject a colored-corner spurious feature at
# correlation rho into PneumoniaMNIST and run standard vs. grokking
# in parallel. Both detached under nohup.
#
# Defaults:
#   GPU_STD=0  GPU_GROK=0      (single-GPU box; both share GPU 0)
#   N_TRAIN=500  SEED=42
#   RHO=0.8                    (val plateau ceiling for the shortcut)
#   WD_GROK=5e-3               (elevated WD; Goldilocks zone fix —
#                              previous run showed ‖W‖ climbing instead
#                              of decreasing, so wd=1e-3 was too weak)
#   WANDB_MODE=offline         (logs to disk; sync later)

set -euo pipefail

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "${ROOT}"

GPU_STD="${GPU_STD:-0}"
GPU_GROK="${GPU_GROK:-0}"
N_TRAIN="${N_TRAIN:-500}"
SEED="${SEED:-42}"
RHO="${RHO:-0.8}"
WD_GROK="${WD_GROK:-5e-3}"
export WANDB_MODE="${WANDB_MODE:-offline}"

echo "Spurious-feature variant — rho=${RHO}, n_train=${N_TRAIN}, seed=${SEED}"
echo "  standard run on GPU ${GPU_STD}  (default WD)"
echo "  grokking run on GPU ${GPU_GROK} (WD=${WD_GROK})"

# RUN_TAG slug (e.g. 0.8 → "spurious08", 0.95 → "spurious095") so the
# run_dir clearly identifies the spurious variant on disk.
RHO_SLUG="spurious$(echo "${RHO}" | tr -d '.')"

EXTRA_ARGS="--spurious_rho ${RHO}" \
RUN_TAG="${RHO_SLUG}" \
  bash scripts/launch.sh standard "${N_TRAIN}" "${SEED}" "${GPU_STD}"

EXTRA_ARGS="--spurious_rho ${RHO} --weight_decay ${WD_GROK}" \
RUN_TAG="${RHO_SLUG}" \
  bash scripts/launch.sh grokking "${N_TRAIN}" "${SEED}" "${GPU_GROK}"

echo
echo "Both spurious runs detached. Watch with:"
echo "  bash scripts/list_runs.sh"
echo "  tail -f experiments/runs/<run_id>/logs/train.log"
echo
echo "Decision numbers will be in summary.json when each finishes."