Keras with TensorFlow on Windows – Iris Example

The Keras code library can be used to create neural network prediction systems. Keras is a (relatively) high-level library that can use the lower-level CNTK or TensorFlow or Theano libraries. The idea is that you can code with CNTK, TF, or Theano directly, but it’s very difficult. Keras makes things somewhat simpler.

TensorFlow is the most common engine for Keras. But TF was designed for Linux systems. About a nine months ago I tried using TF on a Windows machine, and it wasn’t a happy experience. I thought I’d revisit Keras with TF on Windows. Bottom line: everything worked very well.

First I installed Anaconda version 4.1.1 with Python 3.5. Then I used pip to install TensorFlow 1.4.0. And then I used pip to install Keras 2.1.3.

I used the standard Hello World example of machine learning, the Iris Dataset. After a couple of hours, I got a demo up and running.

There were a few glitches. One minor annoyance is that when you train with Keras using the fit() function, you can print loss/error and accuracy metrics every iteration, or not print anything. Too much or too little. It’s important to monitor loss/error during training because training often fails and you want to cancel as soon as possible rather than wait for hours and only then find out that training started failing immediately.

In my demo, I trained silently but I captured the 1000 training iteration history. After training completed, I displayed metrics every 100 iterations. Looks nice but defeats the purpose of monitoring loss/error.

I’ll snoop around the Keras source code and see if there’s a way to modify fit() so that it only prints metrics when you want them.

Moral of the story: On Windows, the CNTK library is still my deep learning library of choice, but Keras with TensorFlow is now an excellent alternative.


“Layers” – Balwina van den Brandeler

This entry was posted in Machine Learning. Bookmark the permalink.