This repository provides a PyTorch package for Truncated Variational Optimization. See related publications below. To get started, check out the examples.
Clone this repository:
git clone [email protected]:tvlearn/tvo.git
We recommend Anaconda to manage the installation, and to create a new environment for hosting installed packages:
$ conda create -n tvo python==3.8.10 gcc_linux-64
$ conda activate tvo
For large problem sizes, we recommend distributed execution of the algorithms using CPU and/or GPU parallelization. To enable MPI-based CPU parallelization, follow the steps described under Installing PyTorch with MPI support below. To enable execution on GPU, make sure to have the CUDA Toolkit installed, e.g. via conda install -c anaconda cudatoolkit
.
Next, the packages specified in requirements.txt
can be installed. If you have installed PyTorch from source for MPI support, comment out the packages torch
and torchvision
. Mac users can comment out gcc_linux-64
. You can then run:
$ pip install -r requirements.txt
Finally, TVO can be set up:
$ cd tvo
$ python setup.py build_ext
$ python setup.py install # optionally replace install by develop to facilitate development
Running the examples additionally requires an installation of tvutil, e.g. via:
$ cd ..
$ git clone [email protected]:tvlearn/tvutil.git
$ cd tvutil
$ python setup.py install
Unit tests are implemented in test and can be executed via:
python setup.py build_ext --inplace # compile extension modules
pytest test # run tests
This step is optional and only relevant for large scale applications of the algorithms.
First, you need to install MPI (please consult the official documentation of mpi4py and MPICH if you need help), e.g. via:
$ sudo apt install mpich
$ MPICC=$(which mpicc) pip install mpi4py
Once MPICH is installed, you are ready to install PyTorch from source:
$ conda install -c conda-forge typing_extensions numpy ninja pyyaml mkl mkl-include setuptools cmake cffi future six requests dataclasses
$ git clone --recursive https://github.com/pytorch/pytorch
$ cd pytorch
$ export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
$ python setup.py install
Jakob Drefs*, Enrico Guiraud*, Filippos Panagiotou, Jörg Lücke. Direct Evolutionary Optimization of Variational Autoencoders With Binary Latents. Joint European Conference on Machine Learning and Knowledge Discovery in Databases, Springer, Cham, 2022, accepted. *Joint first authorship. (online access, code for experiments)
Jakob Drefs, Enrico Guiraud, Jörg Lücke. Evolutionary Variational Optimization of Generative Models. Journal of Machine Learning Research 23(21):1-51, 2022. (online access)
Jörg Lücke, Zhenwen Dai, Georgios Exarchakis. Truncated Variational Sampling for ‘Black Box’ Optimization of Generative Models. International Conference on Latent Variable Analysis and Signal Separation, Springer, Cham, 2018. (online access)
Jörg Lücke. Truncated Variational Expectation Maximization. arXiv preprint arXiv:1610.03113, 2019. (online access)