×

PyPi TensorFlow

It is a free open-source library for high-performative numerical computations. The architecture of TensorFlow allows us for easy deployment and computing across a varied number of platforms and from desktops to clusters servers of mobile and edge devices.

It is developed by the Google Brain team of engineers and researchers from Google's AI organization. It comes along with strong support for deep learning, machine learning, and varied numerical computation is used across many domains.

Features

  • It has features that define, optimize and calculate mathematical expressions using multi-dimensional arrays called tensors.
  • It includes good support for the development of machine learning and deep learning neural networks.
  • It has high scalable features for computation with various datasets.
  • It uses GPU computing automating management and a unique feature for optimization of memory and dataset.

Installation of TensorFlow

"python" is mandatory to install TensorFlow in our system.

In the windows operating system, follow the below steps to install TensorFlow.

Step 1: python version presented in the system should be verified.

PyPi TensorFlow

Step 2: Any mechanism can be used to install TensorFlow but it is advised to use "Anaconda" and "pip". The command "pip" is used to install modules in python.

Anaconda framework should be installed previously to TensorFlow.

PyPi TensorFlow

After installation, check with the "conda" command. The command execution is displayed as:

PyPi TensorFlow

Step 3: To install TensorFlow execute the below command.

conda create --name tensorflow python = 3.5
PyPi TensorFlow

It downloads all the necessary packages for the setup

Step 4: After successful set up of the environment we should activate TensorFlow.

activate tensorflow
PyPi TensorFlow

Step 5: We use pip for installing TensorFlow in the system.

pip install tensorflow
PyPi TensorFlow

TensorFlow

TensorFlow is a basic software library for numerical computing using dataflow graphs where,

  • Node: It represents mathematical operations.
  • Edge: It represents a multi-dimensional array called Tensors.

Note: A tensor is a central unit of data in TensorFlow

Consider the below diagram:

PyPi TensorFlow

Here, mul is a node that represents multiplication operation. Here, a and b are called as input (or) incoming tensors, and c is the resulting (or) output tensor.

The flexible architecture of tensors allows us to compute on more than one CPU or GPU in a system or server or a mobile application with a single API.

APIs in TensorFlow

TensorFlow provides us with many APIs (Application Programming Interface). But they can be classified majorly into two categories:

  1. Low-level API
  2. High-level API

1. Low-level API

  • It has complete programming control.
  • It is recommended mostly for machine learning researchers.
  • It provides us with fine levels of control over the modules.
  • TensorFlow Core is an example of a low-level API.

2. High-level API

  • It is built on top of the other low-level APIs.
  • It is easier to learn and use than other low-level APIs.
  • Between multiple users, it makes repetition easier and more consistent.

Let us consider an example program in python using TensorFlow.

Example

# importing tensorflow
import tensorflow as tf
# creating nodes of computational graphs
node_a = tf.constant ( 4, dtype = tf.int32 )
node_b = tf.constant ( 5, dtype = tf.int32 )
node_c = tf.add ( node_a, node_b )
# creating object for tensorflow session
s = tf.Session()
# evaluating node_c and printing of result
print( " addtion of node_a and node_b is :  ", s.run(node_c) )
# closing the session object
s.close()

Output

sum of node_a and node_b is : 9

Explanation of above code

Step 1: Creating a computational graph.

Creating a computational graph means defining the nodes. TensorFlow provides us with different types of nodes for different types of tasks. Each node takes zero or more tensors as inputs and produces an output as a tensor.

  • In the above program, the nodes node_a and node_b are of tf.constant type. A node that takes no inputs is called a constant node. It outputs value is stored internally.

NOTE: dtype argument is used to specify the data type of the output

node_a = tf.constant ( 4, dtype = tf.int32 )
node_b = tf.constant ( 5, dtype = tf.int32 )
  • The node node_c is of tf.add type which, takes two tensors as input and gives the resultant value as the output tensor.
node_c = tf.add ( node_a, node_b )

Step 2: Running of a computational graph

A session must be created to run a computational graph.

s = tf.Session()

Now, we should use run method for performing computations

print( " addtioon of node_a and node_b is :  ", s.run(node_c) )

Finally, we should use close method to close the method.

s.close()

Related Topics

Data Structures and Algorithms using Python | Part 2

Files: A file is a location or information stored in computer storage devices. File handling is essential when the information or the data is to be held permanently. When we try to...

20 minutes read.

Static Variables in Python

What is a Static Variable? The variable that remains with a constant value throughout the program or throughout the class is known as a " Static Variable ". Static variables are...

3 minutes read.

Python Breakpoint

Introduction In Python 3.7, a brand-new created function called breakpoint() was added. Due to the close relationship between both the executable and the code of a debugging component, debugging Python programming...

4 minutes read.

How to get current date in python?

How to get current date in python? In Python programming language, date and time are not just a data form, but it is possible to import a method called datetime to operate...

3 minutes read.

Python Support

Python Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

3 minutes read.

Python Keywords

If you are trying to learn a programming language, you need to have a basic idea of "What are keywords" and "How they are used". You can learn about keywords in...

7 minutes read.

Isodate Python

Python Programming Language Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It...

3 minutes read.

Python Program to Find the gcd of Two Numbers

Introduction Greatest Common Divisor is the full form of gcd. The greatest common divisor, or GCD, of two numbers, is a value that can exactly divide the two digits and is...

5 minutes read.

Python Control Flow Statements

This article aims to introduce you to what control flow statements are in general and Control Flow Statements in Python programming Language, the Importance of control flow statements and look...

3 minutes read.

_name_ in Python

Introduction: The code at level 0 indentation is to be performed when the command to run a Python program is supplied to the interpreter because Python does not have a main() function...

4 minutes read.

Pltpcolor in Python

Python: Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It is said...

3 minutes read.

Data Drop in Python

Introduction You'll understand how to delete a group of rows from a Pandas dataframe in this article.You can read this article on How to Drop Columns in Pandas to find out...

6 minutes read.

Operator Overloading in Python

In any programming language, + is an arithmetic operator; it adds two numbers to give the sum. Have you ever tried to concatenate two strings? Concatenating two strings is adding...

5 minutes read.

Google Chrome API in Python

Python: Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

3 minutes read.

Python open() function

Python open() function The open() function in Python opens a file and returns a corresponding file object. If the file cannot be opened, an OSError is raised. Syntax open(file, mode='r', buffering=1, encoding=None, errors=None, newline=None, closefd=True, opener=None) Parameter file It represents the path and name of the file mode...

2 minutes read.

How to Fix an EOF Error in Python?

Introduction An EOF (End-of-File) error occurs when a program tries to read beyond the end of a file or a stream, causing it to return an error message. It can happen...

8 minutes read.

Python Glob

Methods for matching files that include particular patterns in accordance with UNIX shell-related expansion rules are referred to as "glob" methods. Similar methods for finding, locating, and searching for all of...

12 minutes read.

How To Compare Two Strings In Python

In this article, we will discuss how to compare two strings in Python. So, before that, let’s have a quick revision on “What are strings?” Strings are a sequence of characters that...

5 minutes read.

Python Tricks: The Book

A Buffet of Awesome Python Features Dan Bader is the author of the book called Python Tricks . he is the owner and editor of Real Python and one of the...

3 minutes read.

GUI Calendar using PyQt5 in Python

GUI: One of the most significant factors that increased the usability of computer and digital technologies for common, less tech-savvy users is likely the development and widespread adoption of GUIs. GUIs...

3 minutes read.