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).