In first we should ask our self about correct definition to “TensorFlow”?
Tensorflow is package contain of open source library and this library contain of many features like numerical computing , Deep learning ,AI,and Image processing.
After that we should to know how TensorFlow work with python: The TensorFlow is already define in Python Environment user should import it by this line code:
impor tensorflow as tf
when done from calling tensorflow we will explain TensorFlow structure it is divide into 3 main items :
- Node: it explain how compute done in nodes and how data move between nodes it is called "Tensors".
- Operations: it is Explain process that done on node and produce output
- Edges: it explain graph that show flow of data , looping and updates state .
Example show how make session on TensorFlow and how perform computation
How to get the value of a?
Create a session, assign it to variable sess so we can call it later Within the session, evaluate the graph to fetch the value of a Code:
Import tensorflow as tef session=tef.Session() v1=tef.constant(20) v2=tef.constant(30) print(session.run(v1+v2))
Output will be: 50
But what’s a Tensor?
- Formally, tensors are multilinear maps from vector spaces to the real numbers ( vector space, and dual space)
- A scalar is a tensor ( )
- A vector is a tensor ( )
- Common to have fixed basis, so a tensor can be represented as a multidimensional array of numbers
. TensorFlow Image Processing.
Mostly used by Social Media, Telecom and Handset Manufacturers;
Face Recognition, Image Search, Motion Detection, Machine Vision and Photo Clustering can be used also in Automotive, Aviation and Healthcare Industries.
Image Recognition aims to recognize and identify people and objects in images as well as understanding the content and context.
TensorFlow image processing algorithms show and identify arbitrary objects within larger images.
This is usually used in engineering applications to identify shapes for modeling purposes (3D space construction from 2D images) and by social networks for photo tagging (Facebook’s Deep Face).
By analyzing thousands of photos of trees for example, the technology can learn to identify a tree it has never seen before
To put part of a graph on a specific CPU or GPU:
Creates a graph.
with tf.device('/gpu:2'): a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], name='a') b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], name='b') c = tf.matmul(a, b)
Creates a session with log_device_placement
set to True. sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) # Runs the op. print sess.run(c)
TensorFlow Variables (3)
- TensorFlow variables must be initialized before they have values! Contrast with constant tensors.:
W = tf.Variable(tf.zeros((2,2)), name="weights") R = tf.Variable(tf.random_normal((2,2)), name="random_weights")
Variable Scope (1)
- Complicated TensorFlow models can have hundreds of variables.
tf.variable_scope()provides simple name-spacing to avoid clashes.
tf.get_variable()creates/accesses variables from within a variable scope.
Tensorflow graph advantages :
- Save computation (only run subgraphs that lead to the values you want to fetch)
- Break computation into small, differential pieces to facilitates auto-differentiation
- Facilitate distributed computation, spread the work across multiple CPUs, GPUs, or devices
- Many common machine learning models are commonly taught and visualized as directed graphs already