Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a tensorflow session actually?

What does the sentence below quoted from getting started with tensorflow mean?

A session encapsulates the control and state of the TensorFlow runtime.

I know encapsulation in object oriented programming, and also have played with session a bit with success. Still I do not get this sentence very well. Can someone rephrase it in simple words?

like image 895
user25004 Avatar asked Apr 20 '17 21:04

user25004


People also ask

What is session in deep learning?

A session is an environment of a software system that describes how the lines of code should run. In TensorFlow, a session sets up how the hardware devices (such as CPU and GPU) talk to each other. That way, you can design your machine-learning algorithm without worrying about micromanaging the hardware it runs on.

Does TensorFlow 2 USE sessions?

Tensorflow 2 does not require session.

What is session return TensorFlow?

Syntax of sess. It will run operations and evaluate tensors in fetches. We must notice its return value. If fetches is a tensor, it will return a single value. If fetches is a list, it will return a list.


1 Answers

This encapsulation has nothing to do with OOP encapsulation. A slightly better (in terms of understanding for a new-comer) definition is in session documentation.

A Session object encapsulates the environment in which Operation objects are executed, and Tensor objects are evaluated.

Which means that none the operators and variables defined in the graph-definition part are being executed. For example nothing is being executed/calculated here

a = tf.Variable(tf.random_normal([3, 3], stddev=1.)
b = tf.Variable(tf.random_normal([3, 3], stddev=1.)
c = a + b

You will not get the values of a tensors a/b/c now. There values will be evaluated only inside of the Session.

like image 120
Salvador Dali Avatar answered Oct 04 '22 14:10

Salvador Dali