What is Tensorflow?

Understanding the Basics behind Google’s Machine Learning Library

Garrett Williams
6 min readSep 27, 2021

Before Covid-19, when international travel was popular, visiting a new country can be an exciting time. It’s not every day that you get to experience a new culture. I’ve had the privilege to visit Australia and I loved every minute of it. Luckily for me, I’m fluent in English and I didn’t have to learn a new language, but I can imagine how this can add some stress to a trip. Enter Google Translate. This application can be used to translate speech, text, or images in real-time, leaving you with less stress and more opportunities to enjoy your trip. This is done using TensorFlow. Before we go over TensorFlow and give an example, let’s start with the foundations of Machine Learning.

Machine Learning

Machine Learning is the process of computers finding patterns in large amounts of data to enable decision-making. This process is constantly repeating because of their ability to learn from their experience and improve themselves without any extra code. Computers can do this through statistical modeling. Essentially, the Machines receive the data and then use mathematical methods to approximate an outcome, all within seconds. This allows computer programs to learn from the past and make updated decisions. Let me give you a real-world example of machine learning to help illustrate its benefit to mankind.

Machine Learning Example

Doctors using IBM Watson Genomics to diagnose cancer patients

Many of us have had a loved one affected by cancer. With hundreds of thousands of new medical studies being published every year, doctors can’t stay on top of all the latest articles and trials. To add insult to injury, a majority of cancer care in the United States is done in community hospitals where they don’t have all the necessary resources. IBM developed a machine learning tool, Watson Genomics, to help Oncologists better serve patients. It can read millions of scientific articles and treatments to give the doctors a particular diagnosis for the patient in real-time. This results in many lives being saved because of the speed and precision of Machine Learning.

TensorFlow

Now that we have a general understanding of Machine Learning, let’s talk about TensorFlow. By definition, TensorFlow is an open-source software library used for machine learning. Written in 3 languages (Python, C++, and CUDA), it was first created in 2015 by Google’s AI team for internal Google use. Tensorflow is structured using tensors and nodes. The software inputs data as multi-dimensional arrays, also known as tensors. You can then construct a flow chart of mathematical operations, also known as nodes, that you want to perform on the inputted data, outputting one or more tensors. This flow of inputting and outputting tensors using nodes is where they came up with the name TensorFlow.

Basic illustration showing the flow of tensors (i.e. multidimensional arrays) being operated on by nodes (i.e. operators). Hence the name TensorFlow!
A more complex, real-world illustration that still uses the basic TensorFlow model to predict a type of Iris

Reasons People Use TensorFlow

One reason why TensorFlow is popular is that it’s extremely fast and precise. It’s also very versatile. It can be run on a desktop or mobile device, and it can run on a GPU or a CPU. Another reason people tend to use TensorFlow is because of Tensorboard, a tool that allows you to visualize your Machine Learning model. The final reason why TensorFlow is popular is that it’s an open-source library developed and maintained by Google, a trusted tech giant. That means anyone could use it for machine learning at no cost without worrying about resources or reliability.

TensorFlow Example

Many of the biggest companies in the world use TensorFlow to deliver a better product. For example, Airbnb uses TensorFlow to classify different images by room and present the most appealing ones at the top of the website (TensorFlow Airbnb Youtube video). This is done by first identifying the different objects in the picture. A porch or a bed or a refrigerator. Once it identifies the probability of correctly classifying each object in the picture, it will use prior knowledge to estimate the probability of correctly identifying the room given the object was right. This flow continues and allows Airbnb to put the best photos first. In the gif below, we can look at a simple example of this process. For each picture, it identifies different features (i.e. eyes, ears, mouth). Using prior knowledge, it can predict the picture is a cat or dog given the data it collected.

Alternatives to TensorFlow

TensorFlow isn’t a monopoly in the software libraries used for machine learning. It has a couple of main alternatives, each with some pros and cons.

PyTorch: Developed by Facebook as an open-source machine learning library. The most important difference between them is that TensorFlow creates a static graph while PyTorch creates a dynamic graph. This means that in TensorFlow, you first need to define the entire graph of the model, then run it. While in PyTorch, you can define and manipulate your graph as you go. Another difference is that TensorFlow has a steeper learning curve, but it has a bigger community behind it. And TensorFlow has TensorBoard which enables you to visualize your Machine Learning model. PyTorch doesn’t have a tool like that.

Scikit-Learn: Also known as sklearn, it’s more of a general-purpose machine learning library while TensorFlow has positioned itself as a deep learning library. Deep Learning is a subset of machine learning that tells the computer to use multiple layers to process the data and fill in the gaps. Sklearn is best used for small to medium-sized projects that require the users to manually process the data and choose the appropriate algorithm. Since it was only written in Python, it doesn’t have the versatility of languages like TensorFlow.

Keras: More of wrapper library that needs to run on top of TensorFlow. It’s best for smaller datasets and more user-friendly, but not as powerful. It should be noted that this isn’t a straight comparison because Keras needs to be run on top of an open-sourced library like TensorFlow

Tutorials

If you would like to learn TensorFlow, below are some websites to check out:

https://www.tensorflow.org/tutorials

https://www.udemy.com/course/complete-guide-to-tensorflow-for-deep-learning-with-python/

https://www.coursera.org/learn/introduction-tensorflow

https://www.udacity.com/course/intro-to-machine-learning-with-tensorflow-nanodegree--nd230

API Documentation

https://www.tensorflow.org/api_docs

--

--