title: Tensorflow Basics - Computing cumulative moving average
body: <p>I've just started with Tensorflow and wanted to know if the below code is right approach to compute cumulative rolling average</p>
  
  <pre><code>import tensorflow as tf
  import numpy as np
  
  x = tf.Variable(0, name = "x")
  x_pld = tf.placeholder(tf.int32)
  update_x = tf.assign(x, x_pld)
  
  curr_avg = tf.Variable(tf.constant(0.), name="curr_avg")
  avg_pld = tf.placeholder("float")
  update_avg = tf.assign(curr_avg, avg_pld)
  
  # Initalize 
  init_op = tf.initialize_all_variables()
  
  with tf.Session() as session:
      session.run(init_op)
  
      for i in range(5):  
          temp_avg = session.run(curr_avg)
          session.run(update_x, feed_dict={x_pld: np.random.randint(1000)})
          new_x = session.run(x)
          print(new_x) 
          session.run(update_avg, feed_dict={avg_pld: ((temp_avg * (i)) + new_x)/(i+1)})
  
      print(session.run(curr_avg))
  </code></pre>