资源算法 pyprob_cpp

pyprob_cpp

2020-01-10 | |  37 |   0 |   0

pyprob_cpp Build Status

pyprob_cpp is a C++ library providing a lightweight interface to the pyprob probabilistic programming library implemented in Python. The two components communicate through the PPX interface that allows execution of models and inference engines in separate programming languages, processes, and machines connected over a network.

Please see the main pyprob documentation for more information.

Installation

Dependencies

Install from source

Please see the provided Dockerfile for more specific instructions on how to install the dependencies and configure the build environment.

git clone git@github.com:pyprob/pyprob_cpp.git
cd pyprob_cpp
mkdir build && cd build && cmake ../src && cmake --build . && make install

Docker

A Docker image with the latest passing commit is automatically pushed to pyprob/pyprob_cpp:latest

https://hub.docker.com/r/pyprob/pyprob_cpp/

Example models

Several example models in C++ are provided in this repository, under the src/pyprob_cpp/test folder.

These mirror the Python test cases in the main pyprob repository and are used as continuous integration tests ensuring that pyprob and pyprob_cpp work seamlessly together.

Here is how a simple model looks like:

#include <pyprob_cpp.h>// Gaussian with unkown mean// http://www.robots.ox.ac.uk/~fwood/assets/pdf/Wood-AISTATS-2014.pdfxt::xarray<double> forward(xt::xarray<double> observation)
{  auto prior_mean = 1;  auto prior_stddev = std::sqrt(5);  auto likelihood_stddev = std::sqrt(2);  auto prior = pyprob_cpp::distributions::Normal(prior_mean, prior_stddev);  auto mu = pyprob_cpp::sample(prior);  auto likelihood = pyprob_cpp::distributions::Normal(mu, likelihood_stddev);  for (auto & o : observation)
  {    pyprob_cpp::observe(likelihood, o);
  }  return mu;
}int main(int argc, char *argv[])
{  auto serverAddress = (argc > 1) ? argv[1] : "tcp://*:5555";
  pyprob_cpp::Model model = pyprob_cpp::Model(forward, xt::xarray<double> {}, "Gaussian with unknown mean C++");
  model.startServer(serverAddress);  return 0;
}

License

pyprob_cpp is distributed under the BSD License.


上一篇:pyprobml

下一篇: neural_collaborative_filtering

用户评价
全部评价

热门资源

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...