Implementation of non-negative matrix factorization on an image dataset via multiplicative updates.
Currently assumes use of CelebA dataset, update IMG_H and IMG_W globals for other datasets.
nmf.py
Runs non-negative matrix factorization according to the following command line arguments:
- num_imgs = number of input images to use from dataset.
- itrs = number of iterations.
- k = factorization rank. Note: larger k pays more accurate reconstructions with longer compute times.
- fp = filepath to your dataset. For the CelebA dataset, point this to the "img_align_celeba" folder.
Example Run:
python nmf.py --num_imgs 4000 --itrs 1000 --k 99 --fp ../data/img_align_celeba
display_mat.py
Displays a sample image, basis vectors, weights, and image reconstructions. The following commands are available:
- num_imgs = number of input images to use from dataset.
- fp = filepath to your dataset. For the CelebA dataset, point this to the "img_align_celeba" folder.
Example Run:
python display_mat.py --num_imgs 4000 --fp ../data/img_align_celeba
References
-
D. D. Lee and H. S. Seung, “Algorithms for non-negative matrix factorization”
-
N. Gillis, “The Why and How of Nonnegative Matrix Factorization”