Alternative Computation Backends for PyMC

Hey everyone,

As some of you here know I have been tasked with exploring the use of Tensorflow as the computational backend for PyMC4.

Here is the link to @twiecki’s post outlining the future of PyMC.

Here is the link to my introductory blog post explaining my approach to tackle this problem.

Future posts related to this project will be found here.

Thank You.


Thank you for working on this! Good luck!

1 Like

This is great. Thank you for sharing and spreading the knowledge. I look forward to reading you blog.

1 Like

Hi everyone. I’m excited that you’re planning to make PyMC useable with alternate computational backends!

As part of a grad class on python this semester, I spent a few Saturdays converting some of the PyMC3 code base so that a user can specify either Theano or Tensorflow as a backend. I changed just enough so that the basic GLM examples work; I commented out all the other code.

The way that I refactored the code is not the best way and its only a very small step, but I thought that I’d share the link to my repo anyway. I ended up using Keras as a model for how to flexibly switch between backends; the way they did it seems very clean. In the jupyter notebook contained in the repo, I also tried to compare things like variable classes between Theano and Tensorflow and contrast things like compiling a function in Theano and running a session in Tensorflow

Sharan, it’s great that you are doing this as your google summer of code project. Looking forward to seeing how PyMC4 comes along!


How “happy” are you with the code changes? Is it worth opening up a PR to the pymc3 repo so that people can inspect the diff? Did the test suite still (mostly) pass?

I’m not super thrilled with the code changes; they were done somewhat quickly to get it done for my project. It also doesn’t pass the tests because I commented out imports to modules that I didn’t need for the basic GLM example. But I’ll submit a pull request and add “[WIP]” just in case someone wants an easier way to look at the changes. If the diff is not too hard to parse for someone else, it might give them ideas for where to start removing some of the explicit references to Theano in each module. Then after some time, you can reject the pull request. (Hope that’s ok).