|
| 1 | +# Phase 2: Ablation Study & Baseline Comparison |
| 2 | + |
| 3 | +This directory contains the code and resources for the Phase 2 ablation study of the SNN-DT project, which now includes a comprehensive comparison against baseline models. |
| 4 | + |
| 5 | +## 1. Installation |
| 6 | + |
| 7 | +Ensure you have the required dependencies installed from the main project's `requirements.txt`: |
| 8 | + |
| 9 | +```bash |
| 10 | +pip install -r ../requirements.txt |
| 11 | +``` |
| 12 | + |
| 13 | +You will also need to install `stable-baselines3`, `pyyaml`, `tqdm`, and `gymnasium`: |
| 14 | + |
| 15 | +```bash |
| 16 | +pip install stable-baselines3 pyyaml tqdm gymnasium |
| 17 | +``` |
| 18 | + |
| 19 | +## 2. Dataset Generation |
| 20 | + |
| 21 | +The new dataset generation process is a multi-stage pipeline that produces high-quality, return-stratified datasets. |
| 22 | + |
| 23 | +### Step 1: Generate Raw Trajectories |
| 24 | + |
| 25 | +First, generate the raw trajectories from random, medium, and expert policies. |
| 26 | + |
| 27 | +```bash |
| 28 | +python scripts/A1_generate_trajectories.py |
| 29 | +``` |
| 30 | + |
| 31 | +This will save the raw trajectories to `ablation_studies/datasets/raw`. |
| 32 | + |
| 33 | +### Step 2: Process Datasets |
| 34 | + |
| 35 | +Next, process the raw trajectories to create the final, stratified datasets. |
| 36 | + |
| 37 | +```bash |
| 38 | +python scripts/B1_process_datasets.py |
| 39 | +``` |
| 40 | + |
| 41 | +This will create `stratified_dataset.npz` and `random_heavy_dataset.npz` in `ablation_studies/datasets/processed` for each environment. |
| 42 | + |
| 43 | +### Step 3: Verify Datasets |
| 44 | + |
| 45 | +Finally, verify the quality of the generated datasets. |
| 46 | + |
| 47 | +```bash |
| 48 | +python scripts/F1_verify_datasets.py |
| 49 | +``` |
| 50 | + |
| 51 | +This will generate distribution plots in `ablation_studies/datasets/verification_plots` and print a spike sanity check to the console. |
| 52 | + |
| 53 | +## 3. Run Experiments |
| 54 | + |
| 55 | +To run an experiment, use the `run_experiment.py` script with the desired variant, environment, and seed. |
| 56 | + |
| 57 | +### Ablation Variants |
| 58 | + |
| 59 | +**Example:** |
| 60 | + |
| 61 | +```bash |
| 62 | +python run_experiment.py --variant full --env CartPole-v1 --seed 1001 |
| 63 | +``` |
| 64 | + |
| 65 | +### Baseline Models |
| 66 | + |
| 67 | +**Example:** |
| 68 | + |
| 69 | +```bash |
| 70 | +python run_experiment.py --variant dt --env CartPole-v1 --seed 1001 |
| 71 | +``` |
| 72 | + |
| 73 | +### Full Experimental Run |
| 74 | + |
| 75 | +You can run all experiments using a simple shell loop: |
| 76 | + |
| 77 | +```bash |
| 78 | +for variant in full no_phase no_routing no_plasticity dt snn_dt iql cql; do |
| 79 | + for env in CartPole-v1 Acrobot-v1 Pendulum-v1; do |
| 80 | + for seed in 1001 1002 1003; do |
| 81 | + echo "--- Running $variant on $env with seed $seed ---" |
| 82 | + python run_experiment.py --variant "$variant" --env "$env" --seed "$seed" |
| 83 | + done |
| 84 | + done |
| 85 | +done |
| 86 | +``` |
| 87 | + |
| 88 | +## 4. Post-process Results |
| 89 | + |
| 90 | +After the experiments are complete, you can generate the plots and summary tables using the `post_process.py` script. |
| 91 | + |
| 92 | +```bash |
| 93 | +python scripts/post_process.py |
| 94 | +``` |
| 95 | + |
| 96 | +This will save the figures to the `ablation_studies/figures` directory. |
0 commit comments