Tensorflow: First Steps

After installing Tensorflow, for example with the last short Tutorial about Tensorflow setup on Windows, some may ask how to start with Tensorflow. Besides the official Tutorials on tensorflow site, which are going deep into the different parts and features of Tensorflow in a comprehensible form, i want to show you two more access points into the topic of deep learning and Tensorflow in particular.

First Contact – jupyter notebook files

In my opinion, the best way to learn about a new python Framework in a very playful manner are prepared jupyter (former iPython) notebook files. Fortunately google is delivering a small but high quality set of notebooks along with the tensorflow github package.
The first notebook hello_tensorflow.ipynb explains the basic principles of working with Tensorflow-tensors and -operators. getting_started.ipynb walks through an example of a very simple neural network for linear regression with gradient descent. The last notebook mnist_from_scratch.ipynb applies Tensorflow to the actual Hello World of Machine Learning, the MNIST handwritten digit dataset.

Udacity – Deep Learning Lecture

Another very nice access point is the Deep Learning Course at Udacity provided by google and held by Vincent Vanhoucke.

Docker: Tensorflow with Jupyter on Windows

If you want to use Tensorflow on a regular basis, there is no good performing alternative to using a native linux or Mac OS installation due to the lack of GPU support. Windows users who just want to take a glimpse at Tensorflow for learning or smaller research purposes however can do so easily by using Docker.

With the following setup, Tensorflow can be used on Windows hosts by using a docker-hostet Jupyter Notebook (former iPython Notebook) from the host browser with local .ipynb files.

Requirements

First, the following software has to be installed on the host. For those never worked with Docker, this short tutorial gives a good overview.

This setup tutorial is based on following path entries:

  • C:\Program Files\Docker Toolbox
  • C:\Program Files\Oracle\VirtualBox

1. Create and configure Docker-Machine

First we have to create and afterwards we configure a new local docker-machine.

Next we have to forward ports 8888 (Jupyter NB) and 6006 (TensorBoard) to be able to use Jupyter Notebook and TensorBoard host-sided:

Instead of using VBoxManage you can use VirtualBox Manager by clicking Docker-Machine-VM->Settings->Network-Port Forwarding.

vbox_port-forwarding

The next step is to share our hosts folder for .ipynb files. Therefore we have to stop the freshly created Docker-Machine and afterwards share the folder (in my case “jupyter_notebooks”) with the docker-machine by using the VBoxManage sharedfolder add command.

Like above, instead of VBoxManage you can use the VirtualBox Manager here: VM->Settings->Shared Folders->add

vbox_shared-folders

2. Start Docker-Machine and “wire up” the shared folders.

By using the following two commands, we start the preconfigured machine and connect to it via ssh.

Afterwards we create a target folder inside of the docker-machine and mount the previously shared folder.

Now you should be able to list the shared folders contents with

3. Run Docker

As last step we can now create our docker container. Like before we forward ports 8888 and 6006 to the container by using the -p flag and again we share our folder by using -v. the source for our container is b.gcr.io/tensorflow/tensorflow from Google Container Registry. With -c we finally give the order to run Jupyter Notebook on our double-shared folder.

Once the sources are pulled, the container is created and Jupyter is started we can open the Notebook from our host browser with localhost:8888 and have Fun with Tensorflow.