Features
- TensorFlow offers multiple levels of abstractions, so we can choose the right one of our needs.
- We can train and build a high-level Keras API, making getting started with TensorFlow and machine learning very easy. If we need more flexibility, Iker execution allows for rapid iteration and intuitive debugging. When we enable eager performance, we will be executing TensorFlow kernels immediately rather than constructing graphs
that will be executed later.
- TensorFlow also supports an ecosystem of powerful add-on libraries and models to experiment.
- TensorFlow's name is derived from its core framework. A Tensor is a matrix of n dimensions. All the operations are inside a graph. The graph is a set of computations that takes place successively.
- TensorFlow allows the developer to create data flow graphs that describe how the data move through a chart or a series of processing nodes.

Source: zdnet.com
- Nodes and the tensors in the TensorFlow are python objects, and TensorFlow applications are themselves python applications. The actual math operations are not performed in Python. The library of transformation data available through TensorFlow is written as high-performance c++ binaries. Python directs the traffic between the pieces and provides high-level programming attraction to hug them together.
TensorFlow Program
1) First import TensorFlow
import tensorflow as tf

You can also try this code with Online Python Compiler
Run Code
2) Declare a Tensorflow constant, say a
a=tf.constant(2)

You can also try this code with Online Python Compiler
Run Code
a is basically a Tensor kind of object
print(a)

You can also try this code with Online Python Compiler
Run Code
Output:
<tf. Tensor 'Const_6.0' shape=( ) dtype=int32>
Here, tf. Tensor denotes the tensor object, Const_6.0 denotes The frequency of declaration of Constant in TensorFlow; in my case, I have created six times TensorFlow constants. The shape represents the shape of the constant, and dtype indicates the datatype. Here, 2 is an Integer.
Note: print( a ) does not print the value of a i.e.2. To print the value(s), we need to create a TensorFlow Session. Using this Session, we call the run function and pass it what to print.
3)
sess = tf. Session( )
print(sess.run( a ))

You can also try this code with Online Python Compiler
Run Code
Output:
2
Similarly, we can add two numbers.
import tensorflow as tf
a= tf.constant( 2 )
b= tf.constant( 3 )
c= a+b
sess=tf.Session( )
print(sess.run ( c ) )

You can also try this code with Online Python Compiler
Run Code
Output:
5
You need not use Session object, sess=tf.Session( ) every time while printing. What we can do is write
with tf.Session( ) as abc
And then directly call evaluate on whatever value you want to print or evaluate.
import tensorflow as tf
a= tf.constant(2)
b= tf.constant(4)
c= a+b
with tf.Session( ) as abc
print(a.eval())
print(b.eval())
print(c.eval())
Output:
2
4
6
FAQs
Q1) What is TensorFlow?
-> TensorFlow is an open-source library for numerical computations and a large-scale machine learning platform.
Q2) How is Google using TensorFlow?
-> Google users can experience a faster and more refined search with Artificial Intelligence. If a user types a keyword in the search bar, google provides the recommendation about the next word. TensorFlow is used by a lot of companies in the industries.
Q3) Is the below code valid ?
a= tf.constant()
b= tf.constant()
-> Yes, the code is valid. Here we aren't changing the constant; we have created another constant with different values. Python variable a is not a constant.
Q4) Is the below code valid ?
a= tf.constant(2)
b= tf.constant(3)
c=tf.add(a,b)
print(c.eval())
->The output shows an error, because the default session is required to be assigned for eval() to work, like eval(Session=sess)
Q5) What are the cons of TensorFlow?
->
- It does not provide support for Open Computing Language.
- It requires prior knowledge of advanced calculus and linear algebra and a pretty good understanding of Machine learning.
- It has GPU memory conflicts with Theano if imported in the same scope.
Key Takeaways
We have reached the end of the discussion of TensorFlow. TensorFlow has excellent usage in Deep Learning.
(must visit: Link)
Thank you🙂🙂