python >= 3.8
We used the following pip package versions, though any up-to-date versions should be fine:
numpy==1.19.2
Pillow==8.0.0
sklearn==0.23.2
pre-commit==2.7.1
wandb==0.10.5
termcolor==1.1.0
Make sure to install all python requirements like so:
pip install -r requirements.txt
Download the ORL and Cropped YaleB datasets, and place them in the code/data
folder. After unzipping the datasets, the code/data
should contain a README
file, along with a folder called CroppedYaleB
containing the YaleB dataset and a folder called ORL
containing the ORL dataset.
By default, code/algorithm/main.py
will run a standard NMF model on a 90% subset of the ORL dataset, with no additional noise applied to the training data. Results will be logged to the terminal as well as to a .jsonl
file in code/algorithm/results
.
To change the type of noise used, you can specify the --noise
parameter along with any additional noise parameters required for the chosen noise type:
Uniform noise:
python code/algorithm/main.py --noise uniform --noise_mean 0 --noise_std 0.1
Gaussian noise:
python code/algorithm/main.py --noise gaussian --noise_mean 0 --noise_std 0.1
Salt and pepper noise:
python code/algorithm/main.py --noise salt_and_pepper --noise_p 0.1 --noise_r 0.5
Missing block noise:
python code/algorithm/main.py --noise missing_block --noise_blocksize 4 --noise_blocks 8
You should only specify the noise parameters for the chosen type of noise, e.g. if using uniform
noise, only specify --noise_mean
and --noise_std
, and not other parameters like --noise_p
.
To change the type of noise used, you can specify the --model
parameter along with either standard
for standard NMF (the default), l1_robust
for RNMF or l21
for L2,1 NMF:
Standard NMF:
python code/algorithm/main.py --model standard
RNMF:
python code/algorithm/main.py --model l1_robust
L2,1 NMF:
python code/algorithm/main.py --model l21
To view additional command line arguments that are not mentioned here, you can use the help command as follows:
python code/algorithm/main.py --help
If you are making changes to the code base, make sure to install the pre-commit
hook for the project to enable automatic code formatting and linting.