Torch / Lua / ugly summation: I don’t know anything about Lua, and that kind of packs sand in my bearings instead of grease. We’re still talking about a library that is geared toward computation heavy work. As much as I like the idea of community supported projects, they never quite feel as polished as something with a corporate logo floating - if silently - in the background. I would show some code using Torch, but it’s definitely different enough that I’m not comfortable digging into it enough to find some bit of code that makes sense to me. Not that it’s too dense for me to do that. I just feel like I would be wasting time on something I have no plans to dig into.
Theano / Python / ugly summation: It’s a Python library that takes complicated computations and gives them to the CPU or GPU in a more efficient language. It is still about tensors and sounds a little like TensorFlow to me. Even the code kind of looks familar, due to being written in Python of course, but also because a library is being invoked to go do math. Theano feels at this point less, I don’t want to say developed, but TensorFlow 1.0 certainly seems to have more going for it at the moment. Torch / Lua / ugly summation: I don’t know anything about Lua, and that kind of packs sand in my bearings instead of grease. We’re still talking about a library that is geared toward computation heavy work. As much as I like the idea of community supported projects, they never quite feel as polished as something with a corporate logo floating - if silently - in the background. I would show some code using Torch, but it’s definitely different enough that I’m not comfortable digging into it enough to find some bit of code that makes sense to me. Not that it’s too dense for me to do that. I just feel like I would be wasting time on something I have no plans to dig into. For now, TensorFlow beat out PyBrain early on, and although Theano remains in the Python arena, I feel like I’ve already made some progress on learning about TensorFlow. Stopping at this point to learn about Theano would be giving in to some attention deficit and I’d rather avoid that. I certainly haven’t become even a beginning moderate expert at TensorFlow, I just think I’m satisfied that it’s a solid direction. Torch, I’m sure is a great library and is supported by a wonderful community, but again, I’m planting my feet on TensorFlow and will delve into learning about making it more accurate at identifying handwritten digits.
What follows is a recounting of my experience with the TensorFlow MNIST for ML Beginners. I took the path of copying the code in the mnist_softmax.py file and running it. $ python /Users/me/Documents/Python/tfbegin.py Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes. Extracting /tmp/tensorflow/mnist/input_data/train-images-idx3-ubyte.gz Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes. Extracting /tmp/tensorflow/mnist/input_data/train-labels-idx1-ubyte.gz Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes. Extracting /tmp/tensorflow/mnist/input_data/t10k-images-idx3-ubyte.gz Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes. Extracting /tmp/tensorflow/mnist/input_data/t10k-labels-idx1-ubyte.gz 0.9147 The result is a decimal that pops out, and to the uninitiated like me, this is so not impressive. I'm reliving all those times I opened a book on C or C++, pecked in the Hello World example and thought to myself..."That's it?" And yeah...that's it. Just this 0.9147 or shy of 92% if you want to think of it as a grade. Except, in machine learning a 92% is a total dunce. Not that I'm qualified to say it, but as the tutorial points out, this is a pretty simplistic model and a refinement of the model could yield results at the 99.7% mark.
So what's going on in the code? The high level view is:
If I'm not focused on the distracting stuff, what does have my attention? I know about importing libraries, and I get the idea of the MNIST data, so my first stop is the model definition. What is going on in that section of code?
Okay, I'm confused a bit because I kind of think of variables as placeholders, so I need a new way to think of variables if they're different from placeholders - which they clearly are in TensorFlow. In TensorFlow, a placeholder allows for the data to be fed into the placeholder at execution. "While you can replace any Tensor with feed data, including variables and constants, the best practice is to use a placeholder op node". That means that placeholders have a very specific purpose particularly in relation to variables and constants which can also be fed, though they shouldn't be fed. What is a variable in TensorFlow anyway? Well, unlike the placeholder, a variable is initialized with a value as opposed to having that value fed to it later. It's easier to see what happens to the placeholder 'x' later during the training and testing of the model. When the training phase of the program executes it feeds data in the 'x' as well as the 'y_' placeholders. Obviously a little more is going on, I plan to read more about this cross_entropy section of the tutorial, but this was interesting. Far more going on than in a simple Hello World application you might write when learning a new language. Speaking of learning a new language, I find it exceptionally helpful that TensorFlow and Python work so well out of the box. I've been looking through the documentation of TensorFlow the last few days, and I'm really starting to find myself getting over PyBrain.
It's not like I fell in love with PyBrain when I began the process and am dumping it at the first glance at some other more curvaceous library. I appreciate that first dip, but in all seriousness, I think TensorFlow is going to prove far more accessible. "We're excited to see people using TensorFlow in over 6000 open-source repositories online." With that in mind, I would like to take a deeper dive into TensorFlow. New Industry Reading link: Google Research for TensorFlow. WHAT?! The deploy section of the TensorFlow site directly talks about distributed TensorFlow server clusters. This is really starting to sound like it's what I was hoping to find. After reading more about Distributed TensorFlow, I'm going to fall back on a familiar phrase, I need to get more comfortable with the basics before I jump straight into the deep end. I don't know the first thing about distributed computing. It's a goal to learn it, and not a prudent starting point. So, let's start an install of TensorFlow on my MacBook Air and see how far we get. Install TensorFlow on OSX: The first question I need to answer is do I want to tackle finding out information about my GPU, so that I can make an informed decision about whether I want GPU support. I'm running this on a MacBook Air, so I'm guessing I don't have "a NVIDIA CUDA GPU meeting the prerequisites". Even if I did, I'm not planning to intentionally " run performance-critical applications". Let's just go for the CPU support only install. Now that there is a decision on which version to install, I need to decide how to install. Since I'm not an expert, installing from sources is out of the question right now. This leaves, virtualenv, native pip, and Docker. Docker doesn't support TensorFlow with GPU support on the Mac which isn't an issue. The hundreds of MBs are not an issue, but still, I don't think I want to bother with Docker. Since I don't have an app in Docker, I don't have a reason to use it. The warnings about cross interference of Python packages and the disabling of SIP make me shy away from doing a native pip install. So...that leaves virtualenv. Step one: install pip Step Two: Upgrade virtualenv Step Three: The command you run Depends on which version of Python you're running. I'm on 2.7. Step Four: Activate the virtualenv. Note the prompt will change after running this command. Step Five: Now we actually install TensorFlow. Because I'm using Python 2.7 and pip is 8.1 or greater, the following command is run. Validate your install, and remember to activate the virtualenv (Step 4) whenever you open a new terminal. |
Disclaimer: The opinions expressed herein are my own. I do not represent my employer, coworkers, mentor, friends, or family in any way on this website or any of its connected social media accounts.
Categories
All
Archives
September 2021
|