This package contains the necessary code to run the experiments associated with the paper Dictionary Learning Under Generative Coefficient Priors. 

Requires: ksvd from https://github.com/nel215/ksvd, scikit-learn, torch, torch-vision, matplotlib

MNIST dataset must be downloaded and location set for variable MNIST_DIR in run.py line 132 and in few-samples-vae.ipynb

The 'Agg' backend of Matplotlib is used for running on a GPU; this can be commented out otherwise.

run.py is the primary script, and running it with different command line arguments will result in different experiments. The command line argument descriptions are included automatically via argparse. Example usages corresponding to the experiments in the paper are as follows:

python run.py --ksvd --altmin --MOD --autodiff --P 30 --epochs 10 --batchfortesting 5 --seed 1 --noise 0.1 --G few_dependencies --name example_dependencies --m 10 --n 9 --dlsparsity --k 3 --saveplots --topk --digits 4

python run.py --MOD --autodiff --altmin --ksvd --P 30 --epochs 9 --batchfortesting 5 --seed 1 --noise 0.1 --G group_sparsity --name example_group_sparsity --m 784 --n 300 --dlsparsity --k 3 --saveplots --topk --digits 4

python run.py --MOD --autodiff --ksvd --altmin --P 30 --epochs 10 --batchfortesting 2 --seed 1 --noise 0.05 --A MNIST_real --G MNIST_real --MNIST_blur --name example_MNIST_blur --n 5 --m 784 --saveplots --numseeds 2 --numinits 2 --topk --digits 4

python run.py --MOD --autodiff --ksvd --altmin --P 30 --epochs 10 --batchfortesting 2 --seed 1 --noise 0.05 --A MNIST_real --G MNIST_real --name example_MNIST_real --n 5 --m 784 --saveplots --numseeds 2 --numinits 2 --topk --digits 4

Running run.py will automatically create a directory called "results" to save output plots, but this can be edited directly in run.py.
