TensorFlow: A First Taste
Why TensorFlow?
There are a lot of good machine learning/deep learning frameworks out there: Caffe, Theano, Torch… but none of them had the same attention level when it first came out as Google’s TensorFlow.
I have been using Caffe for a few months, and I can hardly complain. However, the extensibility of Caffe is arguably weak. Besides, I’d like to try out some fun stuff using LSTM, which is not supported well by Caffe. Theano or Torch? I hear mostly good things about them, but TensorFlow is the fast rising star here.
(By the way there is this very recent arxiv paper comparing popular machine learning/deep learning frameworks, TensorFlow not included.)
Three Things to Note Before Installation
The official guide for TensorFlow installation is not bad. Specifically, I do find virtualenv
easy to use and useful. However, since TensorFlow is still at a very early stage, I wish someone pointed out these three things before installation:
-
Only supports Python 2.7.X
This is mentioned in the Binary Installation section.
-
Only supports protobuf >= 3.0.0
You can check the version of your protoc using
protoc -V
and the version of your protobuf usingpip show protobuf
. Personally I upgraded both protoc and protobuf to 3.0.0.Specifically, I installed
protobuf-3.0.0-beta-1
from source, and upgraded protobuf usingpip uninstall protobuf
andpip install 'protobuf>=3.0.0a3'
following this page. -
Only supports CUDA toolkit 7.0 and cuDNN 6.5 V2
No matter you have a higher or lower CUDA toolkit version, it’s no good. The version number
7.0
is hard-cored in the current TensorFlow scripts.When installing CUDA 7.0, I recommend using
runfile
overdeb
. The interactive installation is very clear and allows you to keep your old toolkit. Ifnvidia-smi
fails after installation, don’t panic. Remember to reboot.
I am sure there will be an elegant official fix for the Python requirement and CUDA+cuDNN requirement in a few months. But if you want to try out TensorFlow NOW, this is what you have to pay ;)
Try MNIST!
If you are reading this post, then you probably want to try the MNIST for Experts instead of for beginners.
Note that in order to run the first line, make sure tensorflow/tensorflow/g3doc/tutorials/mnist
is in your $PYTHONPATH
.
Here is just all of the codes on MNIST for Experts put together, in case you want to run everything at once:
Conclusion
This post is for those who are trying out TensorFlow for the first time. Hopefully with my words, you will save some time during setup.
As of today, judging from the installation process, TensorFlow seems far from mature. If you prefer to use a stable release kind of thing, maybe it’s better to wait a few months.
Happy Thanksgiving!