This library provides the Stein Variational Gradient Descent algorithm in C++. In brief, SVGD is a hybrid (variational + sampling) method that estimates an assumed model using particles. The original work proposed SVGD as a general purpose Bayesian inference algorithm.
- Eigen 3.3+ - can be installed using
apt install libeigen3-dev
- CppAD v20240602+ - from source; when installing, configure your CMake with the following flags:
-D cppad_testvector=eigen
-D include_eigen=true
-D CMAKE_BUILD_TYPE=Release
- OpenMP v4.5+ (201511) - should be shipped with your compiler
- GraphViz - required only if documentation is desired; can be installed using
apt install graphviz
- Doxygen - required only if documentation is desired; can be installed using
apt install doxygen
- Clone this repository and enter it.
- Create a build directory.
$ mkdir build $ cd build
- Configure build flags (the provided values are the default).
$ cmake .. -D BUILD_EXAMPLES=FALSE \ -D BUILD_DOCUMENTATION=FALSE \ -D CMAKE_BUILD_TYPE=Release
- Build and install.
$ make -j $ make install # may require sudo privileges depending on your CMAKE_INSTALL_PREFIX
See the examples directory for tutorials on how to use them and see here for detailed instructions.
Unit tests have been provided to aid source code development. Besides identifying the kinds of testing imposed on the source code, looking into the test files can help you understand how the algorithm works. All you need to do is build the code with -D CMAKE_BUILD_TYPE=Debug
and then run the tests either using CTest
:
# in the build/ directory
$ make test
or run them individually (the tests are written with the doctest
framework):
$ tests/test_model -s