That you calculate "R ^ 2",

Compared to this expression, you are calculating the average in the wrong place. You must accept the average value when calculating errors before performing the separation.
total_error = tf.reduce_sum(tf.square(tf.sub(y, tf.reduce_mean(y))))
unexplained_error = tf.reduce_sum(tf.square(tf.sub(y, prediction)))
R_squared = tf.sub(1, tf.div(unexplained_error, total_error))
source
share