ContextLab / supereeg

Infer activity throughout the brain from a small(ish) number of electrodes using Gaussian process regression
Other
34 stars 14 forks source link

tensorflow backend #4

Open jeremymanning opened 7 years ago

jeremymanning commented 7 years ago

Suggestion from Tim Blakely (Google):

"Depending on the use case, calculating the channels on the fly may be practical (and likely much cheaper). Along those lines, if most/all of the calculations can be expressed as a series of matrix operations, it might be worth some engineering effort to see if the calculations could be ported to TensorFlow. It's the machine learning toolkit we use internally at Google, and while it's mainly used for deep learning and analysis it's actually a generalized platform for doing arbitrary tensor computations (e.g. n-d matrix operations). The reason it might be interesting for your project is that TensorFlow works on both CPUs and GPUs. The latter is particularly useful since 1) it can perform streaming matrix multiplications orders of magnitude faster than CPUs, 2) you can get GCE instances with GPUs in them today, and 3) it may allow for much-closer-to-real-time calculation of SuperEEG channels. Only a suggestion, however; it's by no means a requirement for the project."

jeremymanning commented 7 years ago

The main components that take a lot of time in SuperEEG are: 1) reading stuff into memory from disk (i.e. disk I/O) 2) multiplying big matrices together

TensorFlow could mainly (I think) help with the second issue-- making matrix multiplications faster. We could either implement different steps of the SuperEEG algorithm directly in TensorFlow, or we could use a high-level wrapper for TensorFlow to make the implementation easier.

Some potentially interesting packages I've found:

The other option would be to use Theano instead of TensorFlow (or a Theano wrapper). The downside is that Google's clusters are optimized for TensorFlow, so there's an added bonus for going with TensorFlow. (Theano also has various high-level wrappers.)

andrewheusser commented 7 years ago

Looking through the docs/code a little Keras seems well supported, well documented, pretty intuitive API and wraps both tensorflow and theano (with the same API, i think). may be worth looking into, or bringing it up on your call tomorrow

andrewheusser commented 7 years ago

Actually now that I'm reading more, I'm not sure Keras is appropriate. The API is geared toward creating deep learning models, and what we really want to do is just a series of matrix operations. perhaps, we should just use the tensorflow api directly. Here is a short tutorial from their docs: https://www.tensorflow.org/get_started/get_started doesn't seem TOO bad

jeremymanning commented 7 years ago

Let's get the basic algorithm implemented nicely, and then we can see what it would take to port the relevant pieces to tensorflow...