A Quick Start to Keras and TensorFlow

Keras is a deep learning library designed in the Python language. If you have worked on a deep learning project or are familiar with this area, you have definitely encountered Keras. There are many options in it that will allow you to create deep learning models and provide an environment for us to train our data.

Keras was originally developed to allow researchers to conduct faster trials.

Indeed, Keras is working as fast as possible for data training and pre-processing. If you want to get to know Keras better, you can access their documentation via this link.

Prominent Advantages of Keras

🔹Allows you to perform operations on both the CPU and GPU.

🔹It contains predefined modules for convoluted and iterative networks.

Keras is a deep learning API written in Python that runs on the machine learning platform Theano and TensorFlow.

🔹Keras supports all versions starting with Python 2.7.

Keras, Tensorflow, Theano and CNTK

Keras is the library that offers structures that can realize high-level deep learning models. In this article, we will define the backend engines that we use in our projects many times. Below are these engines running in the background, we include the use of TensorFlow.

Keras Upload

Activation Function

🔹 We can apply the libraries we want to use by selecting them as shown below. There are 3 backend applications that we use. These are TensorFlow, Theano, and Microsoft Cognitive Toolkit (CNTK) backend implementations.

Uploading Library

The platforms you see below are the platforms we encounter a lot in deep learning. As a footnote, I recommend GPU-based work when using TensorFlow. In terms of performance, you will find that with GPU usage, you will get faster and more performance results.

In summary, Keras works in harmony with these 3 libraries. In addition, it works by replacing the backend engine with these three libraries without making any changes to the code. Let’s take a closer look at TensorFlow, which we can use together with Keras.

TensorFlow

➡️ Let’s provide a version check if Python and Pip are installed for the project you are going to work with.

Version Control

➡️ I continue to work for my Mask RCNN project, where I am actively working. You can also create any project or create a segmentation project like me. If you want to continue in the same project, you can access the list of required libraries by clicking on the link.

Collecting Requirements

If you want, you can also upload these libraries one by one. But I require it in terms of being fast.I’m uploading it as a requirements.txt file.

➡️ Let’s go back to Keras and TensorFlow without surprising our goal. We can meet in another article for my Mask RCNN project. Now let’s make a quick introduction to TensorFlow. Let’s import both our project and print the version we use.

TensorFlow

➡️ As you can see as the output, I am using version 2.3.1 of TensorFlow. As I said, You can use it based on CPU or GPU.

Output Version

➡️ Tensorflow as follows when pre-processing the data. We can continue our operations by including the keras.preprocessing module. It seems passive because I am not actively running the method now, but when we write the method that we will use, its color will be activated automatically.

Tensorflow Preprocessing

➡️As an example, we can perform pre-processing with TensorfFlow as follows. We divide our data set into training and testing, and we know that with the validation_split variable, 20% is divided into test data.

In this way, we have made a fast start to Keras and TensorFlow with you. I hope to see you in my next post. Stay healthy ✨

REFERENCES

  1. https://keras.io/about/.
  2. Wikipedia, The free encyclopedia, https://en.wikipedia.org/wiki/Keras.
  3. https://keras.rstudio.com/articles/backend.html.
  4. Francois Chollet, Deep Learning with Python, Publishing Buzdagi.
  5. https://www.tensorflow.org.
  6. https://www.tensorflow.org/tutorials/keras/text_classification.

 

 

Leave a Reply