diff options
| author | YurenHao0426 <Blackhao0426@gmail.com> | 2026-07-21 09:05:52 -0500 |
|---|---|---|
| committer | YurenHao0426 <Blackhao0426@gmail.com> | 2026-07-21 09:05:52 -0500 |
| commit | f2b6107e20975aa649c4ab36b3faab21d1e3c281 (patch) | |
| tree | db10985b39b7f154d5c4ff4efd44e92efec15332 | |
| parent | 887ecfb29478e9a7456a12ea85f7ba7448e7277d (diff) | |
experiments: add canonical depth-2 EP comparison
| -rwxr-xr-x | experiments/analyze_verified.py | 3 | ||||
| -rw-r--r-- | experiments/baseline_run.py | 1 | ||||
| -rwxr-xr-x | experiments/ep_depth2_sweep.sh | 49 |
3 files changed, 53 insertions, 0 deletions
diff --git a/experiments/analyze_verified.py b/experiments/analyze_verified.py index da3c923..a4c4902 100755 --- a/experiments/analyze_verified.py +++ b/experiments/analyze_verified.py @@ -108,6 +108,7 @@ def print_local_baselines(root): os.path.join(root, "pepita_tuned_v1_*.json"), os.path.join(root, "baseline_budget_v1_mnist_ff_*.json"), os.path.join(root, "ep_original_v2_*.json"), + os.path.join(root, "ep_depth2_v1_mnist_ep_*.json"), ]) groups = {} for record in records: @@ -142,6 +143,7 @@ def print_ep_match(root): os.path.join(root, "ep_original_v2_*.json"), os.path.join(root, "ep_match_v1_*.json"), os.path.join(root, "ep_archmatch_v1_*.json"), + os.path.join(root, "ep_depth2_v1_*.json"), ]) groups = {} for record in records: @@ -169,6 +171,7 @@ def provenance_audit(root): os.path.join(root, "ep_original_v2_*.json"), os.path.join(root, "ep_match_v1_*.json"), os.path.join(root, "ep_archmatch_v1_*.json"), + os.path.join(root, "ep_depth2_v1_*.json"), ]) dirty = [r["_path"] for r in records if r.get("provenance", {}).get("git_dirty") is not False] print(f"\n\nProvenance: {len(records)} files audited; {len(dirty)} dirty or unknown.") diff --git a/experiments/baseline_run.py b/experiments/baseline_run.py index 24ad6ae..1ad9f95 100644 --- a/experiments/baseline_run.py +++ b/experiments/baseline_run.py @@ -40,6 +40,7 @@ METHOD_SOURCES = { "ep": { "paper": "https://www.frontiersin.org/journals/computational-neuroscience/articles/10.3389/fncom.2017.00024/full", "code": "https://github.com/bscellier/Towards-a-Biologically-Plausible-Backprop", + "code_revision": "cb73f76d997924b6198355e22b50ed7e97cec684", "protocol": "two-phase energy-gradient dynamics; persistent free particles; random beta sign", }, } diff --git a/experiments/ep_depth2_sweep.sh b/experiments/ep_depth2_sweep.sh new file mode 100755 index 0000000..fa2937b --- /dev/null +++ b/experiments/ep_depth2_sweep.sh @@ -0,0 +1,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 |
