/    /  TensorFlow Sample Program

TensorFlow Sample Program

In this tutorial, we are going to understand writing a first program in TensorFlow.

Writing a first program is always a naive excitement for any programmer to start with. Here is your program to go with.

import tensorflow as tf



x = tf.constant(5.0)

y = tf.constant(10.0)



z = x * y



sess = tf.Session()



print(sess.run(z))

 

The output will be 50.0 if you run the above code sample.

 

Note:

Make sure that you need to install tensorflow before the execution.

 

Let us discuss the above code in detail now:

First we need to import the tensorflow library

Assigning the constants to the variables x and y.

Once after, the statement z=x*y represents the Mathematical calculation of constants x and y.

Then, the session statement means to create the context where we will run the Mathematical operation.

Finally we got the output as 50.0