Search code examples
tensorflowloss-function

Tensorflow - Total Variation Loss - reduce_sum vs reduce_mean?


Why does the Total Variation Loss in Tensorflow suggest to use reduce_sum instead of reduce_mean as a loss function?

This can be used as a loss-function during optimization so as to suppress noise in images. If you have a batch of images, then you should calculate the scalar loss-value as the sum:
loss = tf.reduce_sum(tf.image.total_variation(images))


Solution

  • I contacted the author and it seems there wasn't any important reason behind it at all. He mentioned that maybe reduce_sum worked better for his test case than reduce_mean but encouraged me to test both cases and choose the one which gives me the best results.