title: Cannot optimize using tf.reduce_sum(), but succeeded using tf.reduce_mean()
body: <pre><code>import tensorflow as tf
  import numpy as np
  
  #date generation
  x_data = np.float32(np.random.rand(2, 100))
  y_data = np.dot([0.1, 0.2], x_data) + 0.3
  
  #linear model
  b = tf.Variable(tf.zeros([1]))
  W = tf.Variable(tf.random_uniform([1, 2], -1.0, 1.0))
  y = tf.matmul(W, x_data) + b
  
  #minimize variance
  loss = tf.reduce_sum(tf.square(y - y_data)) #why I cannot use sum here
  optimizer = tf.train.GradientDescentOptimizer(0.01)
  train = optimizer.minimize(loss)
  
  #initialization
  init = tf.global_variables_initializer()
  
  #graph initialization
  sess = tf.Session()
  sess.run(init)
  
  #train network
  for step in range(201):
  sess.run(train)
  #if step % 20 == 0:
  print(step, sess.run(W), sess.run(b), sess.run(loss))
  </code></pre>
  
  <p>Hi, I met a problem while realizing the toy model using tensorflow. When I used <em>tf.reduce_sum()</em> function as the loss function, the optimizer failed to converge. Actually the loss turned to be bigger and bigger. But when I changed the loss function from <em>tf.reduce_sum()</em> to <em>tf.reduce_mean()</em>, the optimizer worked successfully. Anyone can tell why <em>tf.reduce_sum()</em> doesn't work for this model but <em>tf.reduce_mean()</em> does?</p>