**Deep learning is useful for unstructured data.** It allows machines to learn from complex data. In our previous post, we covered how deep learning is powerful. In this post, we will cover an introduction on TensorFlow and Keras open-sourced libraries in Python for deep learning models, and how to use a combination of both to ease tasks.

The use of these two libraries still require the data to go through preparation steps like loading the dataset, imputing missing values, treating categorical variables, normalizing data and creating a validation set.

**Tensorflow**

Tensorflow is an open source software library (created by the Google Brain team). It eases the process of acquiring data, training models, serving predictions, and refining future results. TensorFlow can run on CPU and GPU.

It uses data flow graphs for numerical computation - structures that describe how data moves through a graph, or a series of processing nodes. Nodes in the graph represent mathematical operations. Edges in the graph represent the multidimensional data arrays (tensors) communicated between them.

It excels at numerical computing. It combines the computational algebra of compilation optimization techniques, making easy the calculation of many mathematical expressions that would be difficult to calculate.

It offers more advanced operations than Keras. This comes very handy if you are doing a research or developing some special kind of deep learning models. It offers more control of your network. For example, you can decide which variable should be trainable and should not.

But with more flexibility, TensorFlow is not easy to use. The flexibility comes at a cost of complexity. Therefore, Keras is required to simplify some tasks. In the next part, we will cover Keras and explain how it is different from TensorFlow.

The TensorFlow team is however spending lots of efforts on developing easier-to-use APIs and TensorFlow is evolving rapidly. It has a very large community which supports its development and has gained a lot of momentum lately.

**Keras**

There is also Keras. But you cannot use Keras without an underlying back-end/ engine like TensorFlow, CNTK, or Theano.

It is a high-level neural network API, written in Python. Keras is extremely user-friendly and comparatively easier than TensorFlow. With Keras, you do not need to know the back-end in detail.

If you want to quickly build and test a neural network with minimal lines of code, choose Keras. You can build simple or very complex neural networks within a few minutes with Keras. Keras also runs seamlessly on CPU and GPU.

Keras supports almost all the models of a neural network – fully connected, convolutional, pooling, recurrent, embedding, etc. Furthermore, these models can be combined to build more complex models.

In short, using Keras is like lego blocks and an out-of-box solution. It allows developers to not build from scratch what is already available and commonly used.

Keras provides all the general purpose functionalities for building a deep learning model, but provides less than TensorFlow.

If you want to support custom layers, you can use Keras, but this will have the same complexity with TensorFlow.

**Using Tensorflow with Keras**

Keras + TensorFlow = easier neural network construction! (All you ever need)

Keras is now integrated as part of TensorFlow core API via the "tf.keras" module. This means you can define your model using Keras. And then drop down to TensorFlow if you need specific TensorFlow functionality.

TensorFlow is complex in some areas. Keras makes a great model definition add-on for TensorFlow, as it simplifies many tasks. Keras enables quicks POC's and experiments before launching into full scale build process.

Keras can be used to quickly build base models. These base models if built using TensorFlow will take time to build from scratch.

However, if you need low level changes to your model, Keras will not work (as it is not flexible) and you will need TensorFlow. TensorFlow allows you to deep dive and control low level functionalities.

Essentially, you can code your model and training procedures using the easy to use Keras API and then custom implementations into the model or training process using pure TensorFlow.

In this article, we discussed how TensorFlow and Keras break down foundational barriers to develop deep learning models. It increases development efficiency by knowing which to use. This depends on the task to perform. Deep learning has fast advanced solutions for complex artificial intelligence problems.

Do you use deep learning in your business? Share by leaving us a comment. If you require more information or assistance on predictive analytics, contact us. We want to be an extension of our clients. We assist to systemise processes and decision making. Subscribe to our newsletter for regular feeds.

Did you find this blog post helpful? Share the post! Have feedback or other ideas? We'd love to hear from you.

**References**

InfoWorld, What is TensorFlow? The Machine Learning Library Explained, https://www.infoworld.com/article/3278008/what-is-tensorflow-the-machine-learning-library-explained.html, published on 18 June 2019

Medium, 9 Things You Should Know About TensorFlow, https://medium.com/hackernoon/9-things-you-should-know-about-tensorflow-9cf0a05e4995, published on 7 August 2018

Medium, Build Your First Neural Network Model on a Structured Dataset Using Keras, https://medium.com/analytics-vidhya/build-your-first-neural-network-model-on-a-structured-dataset-using-keras-d9e7de5c6724, published on 20 August 2018

## Comments