BLACK FRIDAY OFFER: Flat 50% Off with Free Self Learning Course | Use Coupon BLACKFRIDAY50

- Data Science Blogs -

How to work with Deep Learning on TensorFlow?



Introduction

The majority of information within the world is unlabeled and unstructured. Shallow neural networks cannot simply capture relevant structure in, for example, images, sound, and matter information. Deep networks square measure capable of discovering hidden structures inside this sort of information. Traditional neural networks think about shallow nets, composed of 1 input, one hidden layer and one output layer. Deep-learning networks square measure distinguished from these standard neural networks having an additional hidden layer, or questionable additional depth. These quite nets square measure capable of discovering hidden structures inside unlabeled and unstructured information (i.e. images, sound, and text), that is that the overwhelming majority of information within the world.  

Deep learning is a man-made brainpower work that emulates the elements of the human mind in planning data and making structures for use in powerful or can say dynamic. Deep learning is a subpart of AI in man-made reasoning that has frameworks fit for taking in independent from data that is unstructured or unlabeled.

TensorFlow is one of the most effective libraries to implement deep learning. TensorFlow may be a code library for numerical computation of mathematical expressional, by using information flow graphs.   The graph comprises of various nodes and each node inside the graph specifies certain mathematical operation and the edges show the flow of data between nodes which is also known as tensors. It is an open-source library created by Google and tailored for Machine Learning. It is originally designed for the task that requires heavy numerical computations. It's being wide accustomed to develop solutions with Deep Learning. Because of the availability of C/C++ in the backend, TensorFlow runs faster than pure Python code.  

Why use TensorFlow?

  • TensorFlow contains two different types of API i.e. Python and C++ but Python is preferred over C++ because it is easy to use.
  • TensorFlow takes very low compilation time when compared to existing libraries.
  • TensorFlow is so much efficient that it provides various functionalities like distributed processing, CPUs, Graphical Processing Unit.

Data flow graphs execution decides the structure of TensorFlow. A data flow graph consists of two main parts:

  1. A node represents the mathematical operations and
  2. An edge represents the multidimensional array which also known as tensors.

The standard usage is to build a graph and execute it after the session is created by using the ‘run’ and ‘eval’ operations. Inputs are fed into nodes through variables or placeholder.

Architecture of TensorFlow

Architecture of TensorFlow

DSWB: Data science workbench

It allows us to deploy computation on one or more CPU, GPU, Android or iOS. All of this can be done using a single API.

Why TensorFlow is suitable for Deep Learning?

  • TensorFlow comes with inbuild provision for neural n/w and deep learning so it is very easier for the end-user to build a n/w, define a parameter and initiate training.
  • As it comprises so many mathematical functions which are easy to train therefore it can be useful in neural networks.
  • Due to the large collection of variants tools, TensorFlow is compatible with many variants of Machine Learning.

Implementation

Python language is used for writing the programs in TensorFlow. Python can be easily downloaded from   https://www.python.org/downloads/.

Now next step is to open a command line as administrator and write the below code for installing Python. 

  • pip3 install --upgrade tensorflow 

For testing the installation enter the following code: 

  • import tensorflow as tf
  • hi = tf.constant(‘Hi!, Welcome to Tensorflow ‘)
  • ssn = tf.Session()
  • print(ssn.run(hi)) 

After running the above code, it will generate the below output.  

        “Hi! Welcome to Tensorflow”

Examples

In TensorFlow, the computation can be explained as data flow and operations in the form of a directed graph.

  • Nodes: Nodes is used to perform computation and it can have 0 or more I/p and o/p. When data travels between various nodes, it is known as tensors, which is nothing but multi-dimensional arrays of values.
  • Edges:  The data flow, branching, looping and updates in states is described by the graph. For the coordination of behaviour inside the graph, various types of edges can be used as computation is incomplete until unless a certain number of inputs is fetched to it.
  • Operation: Operation can be defined as a computation which takes certain input values and based on that input values produces a certain output.

Data Science Training - Using R and Python

  • Learn from the videos anytime anywhere
  • Pocket-friendly mode of learning
  • Complimentary eBook available
  • Discount Voucher on Live-class

The first example is a very basic one which explains the basic functionality like how to create sessions, define constants and how to use these constants and sessions to perform computations.

  • import tensorflow as tf
  • ssn = tf.Session()
  • x = tf.constant(17)
  • y = tf.constant(18)
  • print(ssn.run(a+b))

After running the above code, it will generate the below output.  

  • 35

The next example implements a Linear Regression using TensorFlow.

  • import tensorflow as tf
  • import numpy as np
  • # y = 0.3+x*0.1, hence by using numpy 100 phony x, y data points are created
  • x_data = np.random.rand(100).astype(np.float32)
  • y_data = x_data * 0.1 + 0.3
  • # calculate y_data = b+W * x_data, by finding the values for b and W
  • # Knowing that b should be 0.3 and W 0.1, but it will be sorted out by the tensorflow
  • W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
  • b = tf.Variable(tf.zeros([1]))
  • y = W * x_data + b
  • # mean squared errors is minimized here.
  • loss = tf.reduce_mean(tf.square(y - y_data))
  • optimizer = tf.train.GradientDescentOptimizer(0.5)
  • train = optimizer.minimize(loss)
  • # Before starting, initialize the variables.  We will 'run' this first.
  • init = tf.initialize_all_variables()
  • # Launch the graph.
  • sess = tf.Session()
  • sess.run(init)
  • # Fit the line.
  • for step in xrange(201):
  • sess.run(train)
  • if step == 0:
  • print(step, sess.run(W), sess.run(b))
  • # according to output best fit is W: [0.1], b: [0.3]

After running the above code, it will generate the below output.

Applications:

  1. Object Detection
  2. Speech Emotion Recognition System
  3. Self-Driving Cars
  4. Sentimental Analysis
  5. Image Classification
  6. Text Summarization, etc.

Conclusion

In this blog, we have discussed about TensorFlow and how to work with deep learning on TensorFlow. Firstly, we have discussed in detail regarding the deep learning concepts and TensorFlow basics. Further, we have seen to setup and install TensorFlow on your system and some examples of TensorFlow like how to perform some basic computation and also the linear regression part. Finally, we concluded our discussion by talking about the real-life applications of Deep Learning with TensorFlow.

Please leave query and comments in the comment section. 


    Janbask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


Comments

Trending Courses

AWS

  • AWS & Fundamentals of Linux
  • Amazon Simple Storage Service
  • Elastic Compute Cloud
  • Databases Overview & Amazon Route 53

Upcoming Class

4 days 04 Dec 2020

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing

Upcoming Class

14 days 14 Dec 2020

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning

Upcoming Class

9 days 09 Dec 2020

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation

Upcoming Class

11 days 11 Dec 2020

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

4 days 04 Dec 2020

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing

Upcoming Class

5 days 05 Dec 2020

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum

Upcoming Class

4 days 04 Dec 2020

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design

Upcoming Class

4 days 04 Dec 2020

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation

Upcoming Class

0 day 30 Nov 2020

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks

Upcoming Class

5 days 05 Dec 2020

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning

Upcoming Class

-1 day 29 Nov 2020

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop

Upcoming Class

19 days 19 Dec 2020

Search Posts

Reset

Receive Latest Materials and Offers on Data Science Course

Interviews