Introduction to TensorFlow for Deep Learning

Video Tutorial
FREE
1. Installation on Local Machine. thumbnail
This video belongs to
Keras & TensorFlow for Deep Learning
11 modules
Certificate
Topics Covered

Overview

TensorFlow is an open-source library that supports constructing traditional machine learning and deep learning model. Google developed it to help large computations. However, since we handle more computations for building a model, Deep Learning with TensorFlow would be more compatible. Moreover, both low-level and high-level machine learning APIs are abundant in TensorFlow.

What are Deep Learning Frameworks?

Through a high-level programming interface, deep learning (DL) frameworks provide the building blocks for developing, training, and evaluating deep neural networks without delving into the specifics of underlying algorithms. They offer a straightforward and concise method for defining models using a selection of already constructed and optimized components.

Every framework has been designed differently to serve a unique purpose. Here are some of such frameworks:

  • TensorFlow

  • PyTorch

  • CNTK

  • Caffe

  • mxnet

logo

We can utilize an appropriate framework to assist us in quickly building such a model instead of writing hundreds of lines of code. For example, multi-GPU accelerated training is provided by popular deep learning frameworks like PyTorch, TensorFlow, PyTorch Geometric, DGL, and others rely on GPU-accelerated libraries like cuDNN, NCCL, and DALI for high performance.

What is TensorFlow?

The tensorFlow software library is widely used for numerical computing, the most widely used for creating deep learning tensorflow models. It is scalable and compatible with several operating systems, including Windows, Linux, macOS, and Android. The Google Brain team's researchers and engineers were responsible for its initial development.

tensorflow

Every computation in the deep learning tensorflow model was represented by a data flow graph, also known as computational graphs, in which the node represents operations such as addition or multiplication. Also, Deep Learning with TensorFlow supports execution on different processors like CPUs, GPUs, and TPUs, where tensors are the processing units, and on mobile and embedded platforms. TensorBoard, a visualization toolbox for TensorFlow, offers effective data visualization of network modeling and performance.

The most well-known application of deep learning with TensorFlow has to be Google Translate, which includes features like predicting, tagging, speech/image/handwriting recognition, text classification, and summarization.

Why TensorFlow?

With this library's high-level API, creating neural networks, setting up neurons, and programming neurons don't require extensive coding. TensorFlow for deep learning is easy to start with for beginners. PyTorch is the most loved DL framework.

TensorFlow applications, nodes, and tensors are all Python objects. Python, however, doesn't do mathematical operations. Instead, tensorFlow contains transformation libraries that are high-performance C++ binaries, and Python links the parts by providing high-level programming abstractions and data routing.

TensorFlow has always offered a direct path to production. No matter what language or platform you choose, TensorFlow makes it simple to train and deploy your deep learning tensorflow model on servers, edge devices, or the web. Suppose you require a whole production ML pipeline; use TFX(TensorFlow extended). Use TensorFlow Lite to run inference on mobile and edge devices. TensorFlow.js is used to develop and deploy deep learning tensorflow models in JavaScript environments.

How to Install TensorFlow

you must set up python on your machine to install TensorFlow. We can easily install it through the pip command from the terminal.

Requirements

  • CUDA® architectures 3.5, 5.0, 6.0, 7.0, 7.5, and higher on an NVIDIA® GPU card. Verify the list of GPU cards that support CUDA®.
  • Python 3.7–3.10
  • pip 19.0 or later is required for Linux and Windows (much Linux 2010 support is required). On macOS, pip version 20.3 or later.

Windows

Will install the latest TensorFlow2x on windows.

If you require a specified version, mention the same with the command(i.e., pip install tensorflow == 2.9.0)

macOS

Linux

How TensorFlow Works

Deep Learning with TensorFlow allows you to design dataflow graphs and structures to determine how data traverses a graph by accepting inputs as a multidimensional array called Tensor. A multidimensional data array is a connection between nodes or an edge between them. Nodes in the graph stand in for various mathematical operations. It accepts inputs in a multidimensional array from which you can create a flowchart of the operations.

tensorflow work

TensorFlow Components

Tensor

Tensors are basic units of Tensorflow. An n-dimensional vector or matrix represents it.

TensorFlow gets its name straight from Tensor, the name of its leading framework. Any data can be represented by an n-dimensional vector or matrix called a tensor. The data type and known (or at least partially known) shape of a tensor's values are all the same. The geometry of the data determines the matrix's or array's dimensions.

TensorFlow, with deep learning, only uses graphs to carry out all of its operations. The graph consists of a series of sequential calculations.

Graph

The graph describes all the series computations performed during the training. Therefore, the graph has a lot of advantages, including.

  • The mobility of the graph makes it possible to save computations for use now. All computations on the graph are done by merging tensors. Tensors consist of nodes and edges. 
  • The node performs the calculation and produces the endpoint's output. The connections between the input and output of nodes are described by their edges.

graph

Hello World Program in TensorFlow

Tensor-like objects like the list can be converted into Tensors using the constant() function from TensorFlow. We are going to use this function to run our Hello World program.

Output

Example: Basic Arithmetic Operation

We use TensorFlow's constant() function to create tensors, a basic unit in TensorFlow.

Output

TensorFlow for Deep Learning Setup

You must ensure your system can supply the computational power to run TensorFlow for deep learning algorithms on any dataset. A minimum Intel Core i3 processor with 8 GB of RAM, an NVIDIA GeForce GTX 960 or higher graphics card (or a comparable AMD GPU), and Windows 10 or Ubuntu OS, and these requirements are required. Of course, the gaming laptop would function more quickly and effectively in case of laptops.

Let's examine the subject in depth and discover the procedures you must follow for the installation:

Step 1: Anaconda, a Python and other scientific programming languages, are distributed platforms. Therefore, you must download it and launch the setup file https://www.anaconda.com/products/distribution.

anaconda

Step 2: Download the CUDA toolkit from the Download CUDA toolkit link https://developer.nvidia.com/cuda-toolkit-archive, depending on your GPU and operating system. However, TensorFlow is incompatible with versions 9.1 and 9.2, so it is advised that you get CUDA 9.0  instead.

CUDA

Step 3: Download cuDNN right away from NVIDIA Developers: Intel CuDNN

cuDNN

Step 4: Unzip the downloaded file and paste it into C drive at C:\cudnn-9.0-windows10-x64-v7

Step 5: Add the bin folder path from cuDNN C:\cudnn-9.0-windows10-x64-v7\cuda\bin in Environment Variable in your system.

env

Step 6: Open the Anaconda prompt, and use the following command to create a Conda environment named "tf setup" (you can substitute any other name for "tf_setup").

cmd1

Step 7: then activate the created environment using the activate tf_setup command

Step 8: At Last, inside the environment, you start installing tensorflow with the pip command

cmd2

Where can TensorFlow Run?

TensorFlow's hardware and software requirements can be:

  • In the development phase, you train the deep learning tensorflow model. Typically, you train on a desktop computer or laptop, or Cloud.
  • TensorFlow for deep learning can be utilized on different platforms in the run phase or inference phase after training. For example, you could use it on Windows, macOS, or Linux computers, Cloud as a web service, and smartphones like iOS and Android.

You can train and run the deep learning tensorflow model with GPUs and CPUs. They were initially intended for video games and GPUs. However, late in 2010, Stanford researchers discovered that GPUs rapidly performed these kinds of calculations because they were also very proficient at matrices and algebra. In addition, TensorFlow may be accessed and controlled by other languages, namely Python, although it was implemented in C++.

TensorFlow and CPU, GPU, TPU

Understanding the underlying technologies of CPU, GPU, and TPU is essential to staying current with the rapidly changing technologies for improved performance and efficiency.

The critical distinction between a CPU, GPU, and TPU is that a CPU serves as a computer's central processing unit and is ideally suited for general-purpose programming. Conversely, the GPU is a performance accelerator that improves AI and computer graphics tasks. While TPUs are specially designed Google processors that speed up machine learning and deep learning tasks utilizing TensorFlow.

When to use CPU, GPU, or TPU

To determine which hardware is most appropriate for your workload, consider the kinds of deep learning TensorFlow model you use. You may quickly decide which processors are suitable for your application by following these guidelines:

CPU:

  • Prototypes that require the most adaptability.
  • Basic deep learning tensorflow model that takes little time to train.
  • Using minimal effective batch sizes while training small models.
  • Composed primarily on C++ and using unique TensorFlow methods.
  • Models with constrained system networking bandwidth or limited I/O.

GPU:

  • Deep learning tensorflow models that require a GPU to handle multiple unique TensorFlow operations.
  • Models excluded from the Cloud TPU.
  • Models of medium or greater size and larger effective batch sizes.

TPU:

  • Training models mainly with matrix operations.
  • Training models inside the main training loop without using customized TensorFlow methods.
  • Training models that take weeks or months to complete.
  • Using huge effective batch sizes for training huge models.

Conclusion

  • TensorFlow is a great framework that can compute data graphically and numerically when building deep learning networks. The library is most frequently used for various applications, including Google Search, Google Translate, Google Photos, and many others.

  • The applications for health care, recommendation engines for movies and music, targeted marketing, and emotion mining in social media are just a few of the remarkable things humans have accomplished with deep learning.

  • TensorFlow is a tool that assists in achieving these objectives with these fantastic developments in artificial intelligence, machine learning, and deep learning.

Additional Resources

  1. Deep Learning Interview Questions and Answers