Skip to content

Latest commit

 

History

History

README.md

Experiments and plots

If manual installation produces a ModuleNotFoundError, run export PYTHONPATH=. from the repository root. Most scripts also accept a --path argument to change the default results/ output directory.

This directory contains the small-scale experiments from the ExPLAIND paper and the additional camera-ready ablations. A typical workflow is:

  1. train a model while storing the required model, optimizer, and data checkpoints;
  2. compute EPK predictions and ExPLAIND influence scores from those checkpoints;
  3. run the ablation or plotting script for the experiment section you want to reproduce.

1. Train models with history

Run these scripts from the repository root:

python experiments/train_models/modulo_model.py --path results/modulo_val_results/
python experiments/train_models/cifar2_model.py --path results/cifar2/
python experiments/train_models/mnist10_model.py --path results/mnist10/

The modulo and CIFAR-2 models are the main inputs for the EPK validation, component attribution, pruning, and pipeline experiments. The MNIST model supports the sensitivity and LDS-style data-attribution experiments.

2. Compute EPK predictions and ExPLAIND scores

python experiments/validate_epk/modulo_epk_prediction.py --path results/modulo_val_results/
python experiments/validate_epk/cifar2_epk_prediction.py --path results/cifar2/
python experiments/validate_epk/modulo_epk_train_set.py --path results/modulo_train_epk_new/

These scripts combine prediction of the EPK-reformulated model with influence-score computation to avoid recomputing the same feature maps. The output includes predictions, kernel matrices, and accumulated score statistics used by the plotting scripts.

3. Additional experiments and ablations

Component attribution

python experiments/component_attribution/component_attribution.py
python experiments/component_attribution/comp_att_history.py
python experiments/component_attribution/comp_att_history_train.py
python experiments/component_attribution/comp_train_to_val_hist.py

These scripts aggregate ExPLAIND scores by model component and compare score histories across train and validation behavior.

CIFAR-2 pruning

python experiments/cifar_pruning/model_pruning.py
python experiments/cifar_pruning/plot_pruning_results.py

The pruning experiment removes or perturbs weights based on attribution statistics and plots the effect on model behavior.

Representation pipeline swapping and retraining

python experiments/swap_aligned/swap_pipelines.py
python experiments/retrain_pipeline/retrain_with_pipeline.py
python experiments/retrain_pipeline/plot_pipeline_train.py

These scripts study how intermediate representations change by swapping aligned outer layers and retraining random models initialized from different representation-pipeline states.

Sensitivity and MNIST data attribution

python experiments/sensitivity/mnist_sensitivity.py
python experiments/sensitivity/plot.py
bash experiments/mnist_data_attribution/train_and_attribute.sh
python experiments/mnist_data_attribution/eval_lds.py
python experiments/mnist_data_attribution/plot.py

The sensitivity experiment evaluates score stability under perturbations. The MNIST data-attribution scripts compare ExPLAIND-style scores with LDS-style baselines.

4. Plot regeneration

General plotting utilities live in experiments/plots/:

python experiments/plots/plot_kernel_matrices.py
python experiments/plots/plot_epk_matrices_mod.py
python experiments/plots/plot_mod_epk_stats.py
python experiments/plots/plot_mod_training_process.py
python experiments/plots/plot_kernel_reg_balance.py
python experiments/plots/plot_cosines.py

Most plotting scripts expect artifacts generated by the training and validation steps under results/. If a plot script fails with a missing file, rerun the corresponding training or validation script and check the hard-coded or CLI-configured result path.

Development checks

python -m unittest discover tests
python -m ruff check explaind experiments scaled_experiments tests

Ruff is configured in pyproject.toml; install it in your development environment if python -m ruff is unavailable.