Quickstart: TensorFlow-Examples on PythonAnywhere

Aymeric Damien’s “TensorFlow Examples” repository popped up on Hacker News today, and I decided to take a look. TensorFlow is an Open Source library Machine Intelligence, built by Google, and Aymeric’s examples are not only pretty neat, but they also have IPython notebook versions.

Here’s how I got it all running on a PythonAnywhere account, from a bash console.

$ pip install --user --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
$ git clone git@github.com:aymericdamien/TensorFlow-Examples.git
$ cd TensorFlow-Examples/examples/1\ -\ Introduction/
$ python helloworld.py

That printed out Hello, TensorFlow!, so stuff has clearly installed properly. Let’s train and run a neural net.

$ cd ../3\ -\ Neural\ Networks/
$ python multilayer_perceptron.py

That downloads some test data (a standard set of images of digits), and trains the net to recognise them.

Now, as I’m a paying PythonAnywhere customer, I can run IPython Notebooks. So, on the “Files” tab, I navigated to the TensorFlow subdirectory of my home directory, then went into the notebooks subdirectory, then down into 3 - Neural Networks. I clicked on the multilayer_perceptron.ipynb file, and got a notebook. It told me that it couldn’t find a kernel called “IPython (Python 2.7)", but gave me a list of alternatives – I just picked “Python 2.7” and clicked OK.

Next, I tried to run the notebook (“Cell” menu, “Run all” option). It failed, saying that it couldn’t import input_data. That was easy to fix – it looks like that module (which is the one that downloads the training dataset) is in the repository’s examples subdirectory, but not in the notebooks one. Back to the bash console in a different tab:

$ cp ~/TensorFlow-Examples/examples/3\ -\ Neural\ Networks/input_data.py ~/TensorFlow-Examples/notebooks/3\ -\ Neural\ Networks/

…then back to the notebook, and run all again – and it starts training my network again :-)

Now, the next step – to try to understand what all this stuff actually does, and how it works. I suspect that will be the difficult part.

comments powered by Disqus