TensorStream: Bringing Machine Learning to Ruby
Over the past couple of years we have experienced a big leap in the field of machine learning. Due to fairly recent advances in processing power with GPUs, abundance of data as well as breakthroughs in machine learning research, practical applications in production applications are now mainstream. Examples of these include image recognition software where you can find being used in your favorite photos application as well as in social networks for facial recognition and image classification.
We also have excellent libraries like PyTorch, Keras and TensorFlow which make machine learning accessible to everyone without requiring a masters degree or a PhD. Unfortunately, if you notice those are Python libraries, if you try looking for equivalent ruby libraries or frameworks there are almost none!
There is tensorflow.rb (https://github.com/somaticio/tensorflow.rb) which allows you to call Tensorflow models via ruby (you still have to use python and TensorFlow to build and train the models).
This is unfortunate, as aside from having a big and active community, ruby can bring its elegant and expressive syntax to easily train and create machine learning models.
So, over the past year or so I have been working on TensorStream, a pure ruby machine learning framework (with OpenCL support), with the goal of bringing AI and machine learning to ruby. Internally I have modeled its dataflow architecture based on TensorFlow in order to be able to easily port over its higher level libraries. Though it is my main goal to bring ruby syntax to create elegant models, I also want a framework where the ruby community can participate and improve upon as well as support most ruby implementations (like truffleruby and JRuby) so you can run it almost anywhere you can run ruby.
In my follow up articles I will preview building, training and using an image recognition model in TensorStream. However I already have samples included in my git repositories so go have a look if you want to try it out now.
TensorStream is opensource, and you can find the GitHub project here: https://github.com/jedld/tensor_stream and if your are interested in how OpenCL is used you can check out the OpenCL backend implementation here https://github.com/jedld/tensor_stream-opencl. I intend to have multiple backends in the future including one based on NMatrix/SciRuby so stay tuned.
This project has a long way to go and I appreciate all the help I can get!