Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A C++ extension for SGHMC

Project description


This is a repository created as part of a statistical computation project at Duke University.

The code to be found here is a C++ implementation of SGHMC algorithm wrapped for Python using pybind11. It is further used to verify the results in the original paper on SGHMC: "Stochastic Gradient Hamiltonian Monte Carlo" by Tianqi Chen, Emily B. Fox and Carlos Guestrin.

As seen from our project this is a **15-time-efficiency-improvement** in terms of runtime over the pure python version.

Main files
- **sghmcwrap.cpp** is the original sghmc algo in C++ wrapped for Python

- **** calls and decorates the above extension and tests on an example from the original paper
Packages required to run the code

- The implementation makes use of **Eigen** library for C++ and hence run the following line:
! git clone

Make sure you have it cloned in the same directory as your code.

- **pybind11** and **cppimport** are the two standard packages required for wrapping C++ codes for Python and importing them:
! pip3 install pybind11

! pip3 install cppimport

The example makes use of **sympy** to specify functions (such as potential and kinetic energies as well as the gradient of the former), **numpy** and **numpy.random**.

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for c-sghmc, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size c_sghmc-0.0.2.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page