Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
KnowledgeHut upGradKnowledgeHut upGradBackend Development Bootcamp
  • Self-Paced
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months

What is TensorFlow? How it Works [With Examples]

Updated on 30 November, 2022

5.59K+ views
8 min read

TensorFlow is an open-source library used to build machine learning models. It is an incredible platform for anyone passionate about working with machine learning and artificial intelligence. Furthermore, with the steady growth that the machine learning market is witnessing, tools like TensorFlow have come to the spotlight as tech companies explore the diverse capabilities of AI technology. No doubt, the global machine learning market is projected to reach a valuation of US$ 117.19 billion by 2027.

But on the outset, it is pertinent to know what is TensorFlow and what makes it a popular choice among developers worldwide. 

What is TensorFlow?

TensorFlow is an end-to-end open-source platform for machine learning with a particular focus on deep neural networks. Deep learning is a subset of machine learning that involves the analysis of large-scale unstructured data. Deep learning differs from traditional machine learning in that the latter typically deals with structured data. 

TensorFlow boasts of a flexible and comprehensive collection of libraries, tools, and community resources. It lets developers build and deploy state-of-the-art machine learning-powered applications. One of the best things about TensorFlow is that it uses Python to provide a convenient front-end API for building applications while executing them in high-performance, optimized C++. 

The Google Brain team initially developed the TensorFlow Python deep-learning library for internal use. Since then, the open-source platform has seen tremendous growth in usage in R&D and production systems. 

Some TensorFlow Basics

Now that we have a fundamental idea of what is TensorFlow, it’s time to delve into some more details about the platform. 

Following is a brief overview of some basic concepts related to TensorFlow. We’ll begin with tensors – the core components of TensorFlow from which the platform derives its name.

Tensors

In the TensorFlow Python deep-learning library, a tensor is an array that represents the types of data. Unlike a one-dimensional vector or array or a two-dimensional matrix, a tensor can have n dimensions. In a tensor, the values hold identical data types with a known shape. The shape represents dimensionality. Thus, a vector will be a one-dimensional tensor, a matrix is a two-dimensional tensor, and a scalar would be a zero-dimensional tensor.

Source

Shape

In the TensorFlow Python library, shape refers to the dimensionality of the tensor. 

Source

In the above image, the shape of the tensor is (2,2,2).

Type

The type represents the kind of data that the values in a tensor hold. Typically, all values in a tensor hold an identical data type. The datatypes in TensorFlow are as follows:

  • integers
  • floating point
  • unsigned integers
  • booleans
  • strings
  • integer with quantized ops
  • complex numbers

Graph

A graph is a set of computations that take place successively on input tensors. It comprises an arrangement of nodes representing the mathematical operations in a model.

Session

A session in TensorFlow executes the operations in the graph. It is run to evaluate the nodes in a graph. 

Operators

Operators in TensorFlow are pre-defined mathematical operations. 

How Do Tensors Work?

In TensorFlow, data flow graphs describe how data moves through a series of processing nodes. TensorFlow uses data flow graphs to build models. The graph computations in TensorFlow are facilitated through the interconnections between tensors. 

The n-dimensional tensors are fed to the neural network as input, which goes through several operations to give the output. The graphs have a network of nodes, where each node represents a mathematical operation. But the edge between the nodes is a multidimensional data array or a tensor. A TensorFlow session allows the execution of graphs or parts of graphs. For that, the session allocates resources on one or more machines and holds the actual values of intermediate results and variables.

Source

TensorFlow applications can be run on almost any convenient target, which could be CPUs, GPUs, a cluster in the cloud, a local machine, or Android and iOS devices.

TensorFlow Computation Graph 

A computation graph in TensorFlow is a network of nodes where each node operates multiplication, addition, or evaluates some multivariate equation. In TensorFlow, codes are written to create a graph, run a session, and execute the graph. Every variable we assign becomes a node where we can perform mathematical operations such as multiplication and addition. 

Here’s a simple example to show the creation of a computation graph:

Suppose we want to perform the calculation: F(x,y,z) = (x+y)*z. 

The three variables x, y, and z will translate into three nodes in the graph shown below:

Source

Steps of building the graph:

Step 1: Assign the variables. In this example, the values are:

x = 1, y = 2, and z = 3

Step 2: Add x and y.

Step 3: Multiply z with the sum of x and y.

Finally, we get the result as ‘9.’

In addition to the nodes where we have assigned the variables, the graph has two more nodes – one for the addition operation and another for the multiplication operation. Hence, there are five nodes in all.

Fundamental Programming Elements in TensorFlow

In TensorFlow, we can assign data to three different types of data elements – constants, variables, and placeholders.

Let’s look at what each of these data elements represents.

1. Constants

As evident from the name, constants are parameters with unchanging values. In TensorFlow, a constant is defined using the command tf.constant(). During computation, the values of constants cannot be changed.

Here’s an example:

c = tf.constant(2.0,tf.float32)

d = tf.constant(3.0)

Print (c,d)

2. Variables

Variables allow the addition of new parameters to the graph. The tf.variable() command defines a variable that must be initialized before running the graph in a session.

Here’s an example:

Y = tf.Variable([.4],dtype=tf.float32)

a = tf.Variable([-.4],dtype=tf.float32)

b = tf.placeholder(tf.float32)

linear_model = Y*b+a

3. Placeholders

Using placeholders, one can feed data into a model from the outside. It allows later assignment of values. The command tf.placeholder() defines a placeholder.

Here’s an example:

c = tf.placeholder(tf.float32)

d = c*2

result = sess.run(d,feed_out={c:3.0})

The placeholder is primarily used to feed a model. Data from outside is fed to a graph using a variable name (the variable name in the above example is feed_out). Subsequently while running the session, we specify how we want to feed the data to the model.

Example of a session:

The execution of the graph is done by calling a session. A session is run to evaluate the graph’s nodes, called the TensorFlow runtime. The command sess = tf.Session() creates a session.

Example:

x = tf.constant(3.0)

y = tf.constant(4.0)

z = x+y

sess = tf.Session() #Launching Session

print(sess.run(z)) #Evaluating the Tensor z

In the above example, there are three nodes – x, y, and z. The node ‘z’ is where the mathematical operation is carried out, and subsequently, the result is obtained. Upon creating a session and running the node z, first, the nodes x and y will be created. Then, the addition operation will take place at node z. Hence, we will obtain the result ‘7’.

Advance Your Career in ML and Deep Learning with upGrad

Looking for the best place to know more about what is TensorFlow? Then upGrad is here to assist you in your learning journey.

With a learner base covering 85+ countries, upGrad is South Asia’s largest higher EdTech platform that has impacted more than 500,000 working professionals globally. With world-class faculty, collaborations with industry partners, the latest technology, and the most up-to-date pedagogic practices, upGrad ensures a wholesome and immersive learning experience for its 40,000+ paid learners globally.

The Advanced Certificate Program in Machine learning and Deep Learning is an academically rigorous and industry-relevant 6-months course covering the concepts of Deep Learning. 

Program Highlights:

  •  Prestigious recognition from IIIT Bangalore
  • 240+ hours of content with 5+ case studies and projects, 24+ live sessions, and 15+ expert coaching sessions
  • Comprehensive coverage of 12 tools, languages, and libraries (including TensorFlow)
  • 360-degree career assistance, mentorship sessions, and peer-to-peer networking opportunities

upGrad’s Master of Science in Machine Learning and Artificial Intelligence is an 18-months robust program for those who want to learn and upskill themselves with advanced Machine Learning and cloud technologies.

Program Highlights:

  • Prestigious recognition from Liverpool John Moores University and IIT Madras
  • 650+ hours of content with 25+ case studies and projects, 20+ live sessions, and 8+ coding assignments
  • Comprehensive coverage of 7 tools and programming languages (including TensorFlow)
  • 360-degree career assistance, mentorship sessions, and peer-to-peer networking opportunities

Conclusion

Machine Learning and Artificial Intelligence continue to evolve. What was once the theme of sci-fi movies is now a reality. From Netflix movie recommendations and virtual assistants to self-driving cars and drug discovery, machine learning impacts all dimensions of our lives. Furthermore, with tools like TensorFlow, innovations in machine learning have reached new heights. The open-source library is undoubtedly a boon to developers and budding professionals innovating machine learning-driven technologies. 

So what are you waiting for? Start learning with upGrad today!

Frequently Asked Questions (FAQs)

1. What is TensorFlow used for?

TensorFlow Python is an open-source platform that lets developers create large-scale neural networks. Some of the primary use cases of TensorFlow include text-based applications (such as fraud detection), voice recognition, image recognition, video detection, and analysis of time-series data.

2. Is TensorFlow written in Python or C++?

TensorFlow allows the front-end APIs to be implemented using various languages such as Python, R, C, and C++. However, the runtime in TensorFlow is written using the C++ language.

3. Does TensorFlow need coding?

Since TensorFlow is an open-source library for machine learning, there are four core areas that one needs to master. While coding skills are a must, the other critical components of machine learning education are mathematics and statistics, machine learning theory, and hands-on experience in building machine learning projects from scratch.