A Normalizing Flow model is designed to learn the underlying probability distribution of a given dataset. In a Normalizing Flow model, the input data is transformed through a series of invertible transformations, also known as flow steps. Each flow step consists of a deterministic function that maps the input data to a new representation, and its inverse function that maps the transformed data back to the original space. The key idea behind Normalizing Flow models is that by applying a sequence of invertible transformations, the model can learn a more complex and flexible distribution. This allows the model to capture intricate patterns and dependencies in the data. During training, the parameters of the flow steps are optimized to minimize the difference between the learned distribution and the true distribution of the data. This is typically done by maximizing the likelihood of the training data.
| Argument | Description | Default | Choices |
|---|---|---|---|
--train |
Train model | False |
|
--sample |
Sample model | False |
|
--dataset |
Dataset name | mnist |
mnist, cifar10, fashionmnist, chestmnist, octmnist, tissuemnist, pneumoniamnist, svhn, tinyimagenet, cifar100, places365, dtd, imagenet |
--no_wandb |
Disable Wandb | False |
|
--batch_size |
Batch size | 128 |
|
--n_epochs |
Number of epochs | 100 |
|
--lr |
Learning rate | 1e-3 |
|
--c_hidden |
Hidden units in the first coupling layer | 16 |
|
--multi_scale |
Use multi scale | False |
|
--vardeq |
Use variational dequantization | False |
|
--sample_and_save_freq |
Sample and save frequency | 5 |
|
--checkpoint |
Checkpoint path | None |
|
--outlier_detection |
Outlier detection | False |
|
--out_dataset |
Outlier dataset name | fashionmnist |
mnist, cifar10, cifar100, places365, dtd, fashionmnist, chestmnist, pneumoniamnist, tissuemnist, pneumoniamnist, svhn,tinyimagenet, imagenet |
--n_layers |
Number of layers | 8 |
|
--num_workers |
Number of workers for Dataloader | 0 |
You can find out more about the parameters by checking util.py or by running the following command on the example script:
python VanFlow.py --help
You can train this model with the following command:
python VanFlow.py --train --dataset pneumoniamnist
To sample, please provide the checkpoint:
python VanFlow.py --sample --dataset pneumoniamnist --checkpoint ./../../models/VanillaFlow/VanFlow_pneumoniamnist.pt
Outlier Detection is performed by using the NLL scores generated by the model:
python VanFlow.py --outlier_detection --dataset pneumoniamnist --out_dataset mnist --checkpoint ./../../models/VanillaFlow/VanFlow_pneumoniamnist.pt