TensorFlow basic program

This topic explains a simple addition program using TensorFlow.

import tensorflow as tf
graph = tf.Graph()
with graph.as_default():
    a = tf.Variable(500)
    b = tf.constant(50)
    c = tf.Variable(0)
    Y = tf.assign(c,a+b)
    init = tf.global_variables_initializer()
with tf.Session(graph=graph) as sess:
    init.run()
    print(Y.eval())

result:

550

References :

  1. https://www.tensorflow.org/tutorials/

Comments