Today we are going to dive into the world of Machine Learning with TensorFlow and Keras, two Open Source libraries that allow us to venture into Deep Learning easily.
As we know, learning systems are in fashion. Although there is “a lot of hype” around them, the truth is that there are more than enough reasons for their rise and interest.
Learning systems have a huge field of application ranging from mathematical analysis, making predictions, Business Intelligence, vision systems, autonomous vehicles, robotics, and even medical applications.
Until a few years ago, learning systems were complex, slow, and required quite a bit of programming even for a simple neural network.
But, progressively and driven by the rise of AI and Big Data, libraries like TensorFlow or Keras have appeared that make the process easier and improve the speed of the systems.
Currently, anyone can run and practice with learning systems on a conventional computer, or even on a mini computer like the Raspberry Pi.
So we are going to dedicate this post to introduce these two Machine Learning tools that we will use in the future in the blog’s tutorials.
What is TensorFlow?
Among the many available libraries, the undisputed queen is TensorFlow, which has established itself as the most popular library in Deep Learning. Currently, it would be difficult to imagine tackling a learning project without it.
TensorFlow is a library developed by Google Brain for its machine learning and deep neural network applications, released as open-source software on November 9, 2015.
TensorFlow is a mathematical computation library that executes flow graphs quickly and efficiently. A flow graph is made up of mathematical operations represented on nodes, and whose input and output is a multidimensional vector (or tensor) of data.
The name of the library precisely comes from the union of “tensor” and “flow”
You can find much more information and tutorials on its page https://www.tensorflow.org and the code is available at https://github.com/tensorflow/tensorflow.
What is Keras?
On the other hand, Keras is a neural network library written in Python. It has been developed mainly by François Chollet, a Google engineer, and released as open source.
Keras is an abstraction, a High-level API, for creating learning models. It provides a homogeneous syntax and a simple, modular, and extensible interface for creating neural networks.
Neural networks are a particular type of data flow graph. Therefore, TensorFlow and Keras combine perfectly, forming a tandem that combines power, ease of use, and execution speed. Keras can also run in combination with other “base” frameworks, such as Microsoft Cognitive Toolkit or Theano.
The Keras project website is https://keras.io/, and the source code is available at https://github.com/keras-team/keras/.
Installing TensorFlow and Keras
Installing TensorFlow and Keras is very simple, we only need to have Python pre-installed on our computer.
To install TensorFlow, from a terminal, we run the following command,
pip install tensorflow
Or if we want TensorFlow with GPU support, the following command,
pip install tensorflow_gpu
To install Keras we simply use the command,
pip install keras
At the time of writing this post, the latest supported version of Python is 3.6
Additional Libraries
Other additional libraries that we will frequently use in our learning system projects are
- pathlib Manage file paths
- numpy Mathematical library.
- scipy Mathematical library.
- pandas Data analysis and statistics
- matplotlib Creating graphs
- seaborn Statistical graphs
We can install them, respectively, by doing
pip install pathlib pip install numpy pip install scipy pip install matplotlib pip install pandas pip install seaborn
Hello World in TensorFlow
To check that everything is working correctly, let’s make a simple application with TensorFlow. We create a Python file (for example, TF_HelloWorld.py) and copy the following content.
import tensorflow as tf
hello = tf.constant('Hello world!')
a = tf.constant(2)
b = tf.constant(3)
with tf.Session() as sess:
print(sess.run(hello))
print("A+B = %i" % sess.run(a+b))
print("A*B = %i" % sess.run(a*b))
When we run it, if everything went well, we will see the following output.
b'Hello world!'
A+B = 5
A*B = 6
That’s it for this introduction to TensorFlow and Keras, two libraries that allow us to develop Machine Learning projects easily.
In the future, we will see more tutorials on these two tools, such as regression, classification, prediction, and computer vision. See you soon!

