Keras vs. TensorFlow



Original Source Here

What are the differences between the two?

  1. Neural Networks Basics: Weighting Functions
  2. Training Neural Networks With Keras
  3. Keras vs. TensorFlow (this article)

Now that we have seen an introduction of Keras, let us look at another popular machine learning library called TensorFlow and compare the two libraries. Tensorflow is a utility created by Google that is used to train models. But we haven’t actually seen how to import training data, create models or run models on datasets using Tensorflow. We have only seen how to do it on Keras.

Today we shall see how to do it on Tensorflow as well.

Relationship to Tensorflow

The relationship between these two neural network libraries can be confusing to some people.

Much to a pleasant surprise, Tensorflow bundles Keras as a package. That means you can call Keras functions and class methods from within Tensorflow without installing Keras separately. Keras is available in the tensorflow.keras submodule.

This implies that everything I covered in the last post is also available as-is inside this submodule. fit(), compile(), etc. all have the same names and arguments in this submodule.

But what is also important for you is that Keras is the high-level front-end that can utilize Tensorflow, and other libraries such as CNTK and Theano, in the back-end. So, the situation is that TensorFlow includes the higher-level functions of Keras (which themselves run on the Tensorflow engine since this is the Tensorflow-bundled Keras). It also includes its efficient low-level ML functions.

Why do we need both APIs?

Then why is Tensorflow bundling Keras’ API if its own API is much faster and more streamlined? The answer is because its own API is much more complex and hard to use by some. It is the same reason people use when they say higher-level programming languages such as Java or Ruby are easier to work with than a low-level one such as C++: because they are easier to work with and for people to use. The same logic applies to these two ML libraries.

The lower-level Tensorflow functions tend to be used for huge models that need to run quickly, while the higher-level Keras functions tend to be used for everything else.

The lower-level API

If you really want to see how the lower-level API works in action, I have a few code snippets that exhibit some of Tensorflow’s features. TensorFlow itself has two major versions, version 1 and version 2. For now, I will only show off version 2 code, though I will go through both versions and the examples in more detail in a future article.

Since I cannot directly embed Github source files on this platform, I shall have to link to them instead.

AI/ML

Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot

%d bloggers like this: