-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_random_feature_specgd.sh
More file actions
executable file
·77 lines (67 loc) · 1.81 KB
/
run_random_feature_specgd.sh
File metadata and controls
executable file
·77 lines (67 loc) · 1.81 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_DIR="$SCRIPT_DIR/.venv"
PYTHON_BIN="$ENV_DIR/bin/python"
if [ ! -x "$PYTHON_BIN" ]; then
echo "[specgd] Missing virtual environment. Run $SCRIPT_DIR/install.sh first." >&2
exit 1
fi
OUTPUT_DIR="$SCRIPT_DIR/logs_rf"
mkdir -p "$OUTPUT_DIR"
if [ -n "${RF_EXTRA_ARGS:-}" ]; then
# shellcheck disable=SC2206
EXTRA_ARGS=(${RF_EXTRA_ARGS})
else
EXTRA_ARGS=()
fi
plot_latest_run() {
local latest_json
latest_json=$(ls -t "$OUTPUT_DIR"/*.json 2>/dev/null | head -n 1 || true)
if [ -z "$latest_json" ]; then
echo "[specgd] No JSON log found to plot in $OUTPUT_DIR" >&2
return
fi
echo "[specgd] Plotting random-feature results from $latest_json"
"$PYTHON_BIN" "$SCRIPT_DIR/plot_random_feature_specgd.py" \
--input "$latest_json" \
--output-dir "$OUTPUT_DIR"
}
common_args=(
--plot
--output-dir "$OUTPUT_DIR"
--progress
--specgd-restart-frequency 100
--specgd-from-peak
--num-samples 400
--steps 1000
)
echo "[specgd] Running random_feature_specgd.py (ReLU)..."
rf_relu_cmd=(
"$PYTHON_BIN" "$SCRIPT_DIR/random_feature_specgd.py"
"${common_args[@]}"
)
if ((${#EXTRA_ARGS[@]})); then
rf_relu_cmd+=("${EXTRA_ARGS[@]}")
fi
rf_relu_cmd+=(--activation relu)
"${rf_relu_cmd[@]}"
plot_latest_run
echo "[specgd] Running random_feature_specgd.py (SwiGLU, 400-step variant)..."
rf_swiglu_cmd=(
"$PYTHON_BIN" "$SCRIPT_DIR/random_feature_specgd.py"
--plot
--output-dir "$OUTPUT_DIR"
--progress
--activation swiglu
--specgd-restart-frequency 100
--specgd-from-peak
--num-samples 400
--steps 400
)
if ((${#EXTRA_ARGS[@]})); then
rf_swiglu_cmd+=("${EXTRA_ARGS[@]}")
fi
"${rf_swiglu_cmd[@]}"
plot_latest_run
echo "[specgd] Random-feature experiments complete. Logs saved under $OUTPUT_DIR"