Baylib is a parallel inference library for discrete Bayesian networks supporting approximate inference algorithms both in CPU and GPU.
Here's a list of the main requested features:
- Copy-On-Write semantics for the graph data structure, including the conditional probability table (CPT) of each node
- parallel implementation of the algorithms either using C++17 threads or GPU computing with boost compute
- template-based classes for probability format
- input compatibility with the XDSL format provided by the SMILE library
- cmake-based deployment
- Gibbs Sampling - C++11 threads
- Likelihood Weighting - C++11 threads
- Logic Sampling - GPGPU with boost compute
- Rejection Sampling - C++11 threads
- Adaptive importance sampling - C++11 threads, GPGPU with boost compute
algorithm | evidence | deterministic nodes | multi-threading | GPGPU |
---|---|---|---|---|
gibbs sampling | ✓ | * | ✓ | |
likelihood weighting | ✓ | ✓ | ✓ | |
logic sampling | ✓ | ✓ | ✓ | |
rejection sampling | ✓ | ✓ | ✓ | |
adaptive importance sampling | ✓ | ✓ | ✓ | ✓ |
*It's a very well-known limitation of the Gibbs sampling approach
- cmake >= 2.8
- boost >= 1.65
- libtbb
- ocl-icd-opencl
- mesa-opencl-icd
Under Linux, you can install the required dependencies using the provided script install_dependencies.sh as follows
cd scripts/
chmod u+x install_dependencies.sh
./install_dependencies.sh
Using the cmake FetchContent
directives you can directly setup baylib as follows
include(FetchContent)
FetchContent_Declare(
baylib
GIT_REPOSITORY https://github.com/mspronesti/baylib.git
)
FetchContent_MakeAvailable(baylib)
# create your executable
# and whatever you need for
# your project ...
target_link_libraries(<your_executable> baylib)
Alternatively under Linux or MacOS, you can run the provided script install.sh as follows
cd scripts/
chmod u+x install.sh
sudo ./install.sh
another option for the script is running the following commands (assuming you're in the root of the project):
mkdir build
cd build
cmake ..
make
sudo make install
You can now include baylib
in your projects.
In the latter two cases, make sure your CMakeLists.txt
looks like this
find_package(baylib)
# create your executable
# and whatever you need for
# your project ...
target_link_libraries(<your_executable> baylib)
Baylib allows performing approximate inference on Bayesian Networks loaded from xdsl files or created by hand (either using named nodes or numeric identifiers).
Have a look at examples for more.