- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Tensorflow is a machine learning framework that is provided by Google. It is an open−source framework used in conjunction with Python to implement algorithms, deep learning applications and much more. It is used in research and for production purposes.

It has optimization techniques that help in performing complicated mathematical operations quickly. This is because it uses NumPy and multi−dimensional arrays. These multi−dimensional arrays are also known as ‘tensors’. The framework supports working with deep neural network. It is highly scalable, and comes with many popular datasets.

The ‘tensorflow’ package can be installed on Windows using the below line of code −

pip install tensorflow

Tensor is a data structure used in TensorFlow. It helps connect edges in a flow diagram. This flow diagram is known as the ‘Data flow graph’. Tensors are nothing but multidimensional array or a list.

We will be using the Jupyter Notebook to run these codes. TensorFlow can be installed on Jupyter Notebook using ‘pip install tensorflow’.

Following is an example −

import tensorflow.compat.v1 as tf tf.disable_v2_behavior() import numpy as np mat_1 = tf.constant([[3, 5]]) a = tf.placeholder(tf.int32, shape=(2, 1)) b = tf.placeholder(tf.int32) product = tf.matmul(mat_1, a) + b with tf.Session() as sess: result = sess.run(product, feed_dict={a: np.array([[2],[3]]), b:1}) print(result) result = sess.run(product, feed_dict={a: np.array([[4],[5]]), b:3}) print(result)

[[22]] [[40]]

Import the required packages and provide an alias for it, for ease of use.

The ‘tf.constant’ maps the input data as a constant value. These constants are a apart of the computation graph that runs with the input data.

If a different input data is required, the ‘tf.constant’ can be replaced with ‘tf.placeholder’.

The ‘feed_dict’ function is used to map different input data to placeholder.

The product of the matrices is computed.

This output is displayed on the console.

- Related Questions & Answers
- How can Tensorflow be used to add two matrices using Python?
- How can Tensorflow be used to multiply two matrices using Python?
- How can the ‘Word2Vec’ algorithm be trained using Tensorflow?
- How can BeautifulSoup be used to extract ‘href’ links from a website?
- What are all the ways keyword ‘this’ can be used in Java?
- How can Tensorflow be used to implement custom layers?
- How can Tensorflow and Tensorflow text be used to tokenize string data?
- How can Tensorflow be used to export the model so that it can be used later?
- How can the ‘subplot’ function be used to create two graphs in Matplotlib Python?
- How can Tensorflow be used with boosted trees in Python?
- How can Tensorflow be used to standardize the flower dataset?
- How can Tensorflow text be used to preprocess text data?
- How can Tensorflow be used to compose layers using Python?
- How can TensorFlow Text be used to preprocess sequence modelling?
- How to use ‘while loop’ in Java?

Advertisements