TensorFlow is in a relationship with Keras — Introducing TF 2.0

Google’s TensorFlow team announced its newest and quite easy-to-use version earlier this year. For people who have used any of TensorFlow 1.XX, this version is less ugly, less creepy and more user-friendly (technical updates and changes are discussed below). I will be writing a 3 part series and this serves as the beginning and the shortest one. The theme of these parts are as follow:

  • Introducing TF 2.0
  • Image classification in TensorFlow 2.0
  • Transfer learning in TensorFlow 2.0

What are TensorFlow and Keras?

Wikipedia suggested that TensorFlow is a free and open-source software library for data flow and differentiable programming across a range of tasks. Humanly speaking, TensorFlow is an open source library for building Machine learning models at large scale. It is by far the most popular library for building deep learning models. It also has the strongest and a huge community of developers, researchers and contributors.

Keras is a high-level neural networks API, written in Python and capable of running on top of Tensorflow, Theano or CNTK. It is very popular in the research and development community because it supports rapid experimentation, prototyping and user friendly API. Being user friendly obviously comes up with cost of losing access to inner details of tensorflow, but a reasonable number of complex things can still be done.

What’s new in Tensorflow 2.0

Tensorflow basically works with building a computational graph for any sort of calculation being done; ranging from adding two numbers to building a Generative adversarial network. Once a graph is built, it is executed in a so called session. This might sound like a heavy dose for a beginner (now you might understand why TensorFlow 1 was a bit ugly) and this is why it was really hard, especially for a beginner, to directly jump in to tensorflow to implement neural networks.

With the advent of TensorFlow 2, things have become quite neat, flexible and easy for anyone to get started into the field of deep learning by experimentation. Tensorflow 2 comes up with a tight integration of Keras and an intuitive high level API tf.keras to build neural networks and other ML models. You get the user friendliness of Keras and can also be benefited by access to all low level classes of tensorflow. It is a perfect combination for people in diverse range of industries and expertise to use; and hence a perfect love story of tensorflow and keras.

As per the official commentary on the new features of Tensorflow 2, those can be summarized in three major categories:

Usability

  • With integration of Keras, the usability has become a lot powerful. People with different level of expertise in deep learning can use tensorflow now for their work; this increases usability to a greater extent.
  • One of the biggest changes is the default eager execution mode. In simple terms, you do not need to build graphs and then execute them on sessions to run a basic multiplication operation. You can simply build deep networks on the fly as Keras. This does not deprive you of using graph for its benefits and hence those can be accessed by tf.function.

Clarity

  • Duplicate functionalities have been removed. A lot of cleaning in in the actual code base had been done to remove these.
  • The syntax is more intuitive (thanks to keras) and consistent throughout.

Flexibility

  • As discussed, you can still use low level APIs for different sort of custom tasks.
  • It also provides inheritable interfaces for variables, layers and checkpoints.

The architecture for tensorflow 2 looks like the following.

Tensorflow Architecture

There are a lot more updates and new features in TensorFlow and we will explore them in future blogs of this series. In the next blog, we will discuss how you can start computer vision by building an image classifier with the help of convolutional neural networks in Tensorflow 2. You can check out my previous blog on getting started with computer vision to have an understanding of computer vision. It will help you in going through the coming blogs.

For more updates on tensorflow 2, please visit https://www.tensorflow.org/