summaryrefslogtreecommitdiff
path: root/experiments/traffic_validation_sweep.sh
blob: f7ea4383f599ba0a0fae029dfa341bcabeac8a68 (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
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
# Development-only validation sweep for endogenous non-teaching apical traffic.
# No test-set metric is emitted. Freeze a protocol before creating test results.
#
# Usage:
#   traffic_validation_sweep.sh <gpu> [dataset] [families] [scales] [signals] [seeds]
# Example:
#   traffic_validation_sweep.sh 5 mnist "soma topdown" "0 0.2 0.5" \
#       "raw matched residual taskfit" "0 1"
set -eu

cd "$(dirname "$0")/.."
GPU="${1:?GPU index required}"
DATASET="${2:-mnist}"
FAMILIES="${3:-soma topdown}"
SCALES="${4:-0 0.2 0.5}"
SIGNALS="${5:-raw matched residual taskfit}"
SEEDS="${6:-0}"
PYTHON="${PYTHON:-/home/yurenh2/miniconda3/envs/ep_pascal/bin/python3}"

for seed in $SEEDS; do
  for family in $FAMILIES; do
    for scale in $SCALES; do
      # The zero-traffic condition is family-independent.
      if [ "$scale" = "0" ] && [ "$family" != "soma" ]; then
        continue
      fi
      scale_tag="${scale//./p}"
      for signal in $SIGNALS; do
        use_residual=1
        raw_control=none
        p_neutral=1
        case "$signal" in
          raw)
            use_residual=0
            ;;
          matched)
            use_residual=0
            raw_control=match_innovation_norm
            ;;
          residual)
            ;;
          taskfit)
            p_neutral=0
            ;;
          *)
            echo "unknown signal control: $signal" >&2
            exit 2
            ;;
        esac

        tag="traffic_dev_v1_${DATASET}_${family}_rho${scale_tag}_${signal}_d3_s${seed}"
        out="results/${tag}.json"
        if [ -s "$out" ]; then
          echo "[$tag] exists; skipping"
          continue
        fi
        CUDA_VISIBLE_DEVICES="$GPU" "$PYTHON" experiments/run.py \
          --mode sdil --dataset "$DATASET" --device cuda \
          --depth 3 --width 256 --residual 1 --act tanh \
          --epochs 15 --batch_size 128 --eta 0.05 --momentum 0.9 \
          --eta_A 0.02 --eta_P 0.002 \
          --pert_sigma 0.01 --pert_every 4 --pert_ndirs 16 \
          --pert_mode simultaneous \
          --traffic_mode "$family" --nuis_rho "$scale" \
          --use_residual "$use_residual" --raw_scale_control "$raw_control" \
          --learn_A 1 --learn_P 1 --p_neutral "$p_neutral" \
          --p_warmup_steps 200 --p_warmup_eta 0.05 \
          --val_examples 5000 --split_seed 2027 --eval_split validation \
          --diagnostics alignment --seed "$seed" --log_every 100 --tag "$tag"
      done
    done
  done
done