A project in which we try to work our way to a "factorization" of a probability density over a set of signals, in this setting, images. (
Where heach density assumes the boltzmann form:
Each
-
/srcAll the machinery needed for the model to run. This includes samplers model definition and data imports...data_import.py: Import and preprocessing functions for all the dataset used MNIST, LFW and FMNIST.diagnostic.py: Functions for measuring the quality of the generation and of the "energy landscape" produced by the model.evaluation.py: Calculation of the Freched Inception Distance (FID).gradient_inspect.py: Functions from sampling with langevin dynamics from the EBMinformation.py: Initial implementation of a MINE-like tecnique for estimating the total correlation of the heads.losses.py: Loss functions, later used intrain.MINE.py: Definitive implementation of the MINE inspired head regularizer for the whole model: Functions for computing lower bounds to the total correlation.model.py: Definition of modules and submodules used to implement the EBM.plot.py: Mainly functions for inspecting the gradients of the heads and for plotting grids of samples either from theReplaySampleror freshly generated from the model itself.sampler.py: Home to theReplaySamplerclass, massively important for the training dynamics of presistent contrastive divergence.train.py: Functions for performing a single epoch of training.
-
model_train.ipynb: Setup for a general train run for all of the three main datasets with checpoints in the/models/folder. -
other_models_benchmark.ipynb: Execution of the benchmarks for the other models used for comparison, a variation auto encoder and u-net diffusion model. -
train_other_models.py: File for training the benchmark models (VAE & U-net diffusion). -
test_total_correlation.ipynb: Training of the model with the total correlation regularization defined inMINE.py. -
toy_example.ipynb: Experimentation of the TC regularization on a 1d density.
For building the code of the project first build a local enviroment and install the requirements:
python3 -m venv venv
source ./venv/bin/activate
pip3 install -r requirements.txtAt this point we are using a Deep Convolutional Network for every EH and the output of the entire model it's just a sum over those results. Things to investigate:
- possibility of logsum(output) to make the energy non-negative. This can improve the convergence of the model. In any case in the literature about EBM it's shown how this doesn't improve performances and leads to a collapse around zero value
- possibility to differentiate the architecture for every EH to implicitly bias the distribution towards different levels of details or different kind of aspects of data.
At the moment we are working on a contrastive learning framework, pushing the model to learn high (not sure) energy for good samples and low energy for the ones OOD.
The current loss for the model is formalized over a batch
where
If we treat
- Pearson Correlation
- Pixel-to-pixel linear correlation of the gradients
- Total correlation (what we sticked with)
A possible generalization of mutual information, the difference between the joint entropy of the vector:
being a KL divergence it can be expressed using the Donsker-Vardan theorem, in an alternative form:
We then replace the supremum with a maximization over a set of parametrized functions
The sampling strategy for this kind of project can is a combination of Persistent Contrastive Divergence an Stochastic Gradient Langevin Sampling, a MCMC method that exploit the gradient of the enrgy function to move the current sample towards one with higher energy and adding a gaussian noise factor to favor exploration. The PCD influence is on the fact that we still maintain a persistent chain so we don't initialize at random for every single point but we start from the last point of the previous chain and producing a sample by performing gradient ascent.
Key problems with this approach:
- There is the possibility that the sampler becomes "too good" in finding the lowest points in the energy landscape and produce samples in that direction instead of the one truly modeled. In that case the model is learning to approximate a wrong lanscape.
- Computational cost given by MCMC
- Try with logsum output
- Scheduler on langevin steps
- Langevin sampling on subset of pixel
