Closed iperov closed 6 years ago
tf.histogram_fixed_width is not differentiable to use in loss func.
I created differentiable version for image histogram.
def tf_image_histogram (tf, input): x = input x += 1 / 255.0 output = [] for i in range(256, 0, -1): v = i / 255.0 y = (x - v) * 1000 y = tf.clip_by_value (y, -1.0, 0.0) + 1 output.append ( tf.reduce_sum (y) ) x -= y*v return tf.stack ( output[::-1] )
^ result same as tf.histogram_fixed_width
and with mean square diff
hist_loss = tf.reduce_mean ( tf.square ( ( tf_image_histogram (tf, y_true) - tf_image_histogram(tf, y_pred) ) /65536 ) )
nn finds out nearest set of pixels from noise which represent same histogram
so how to use it to train image histogram ?
tf.histogram_fixed_width is not differentiable to use in loss func.
I created differentiable version for image histogram.
^ result same as tf.histogram_fixed_width
and with mean square diff
nn finds out nearest set of pixels from noise which represent same histogram![python_2018-05-13_09-37-28](https://user-images.githubusercontent.com/8076202/39964238-41e3d7a4-5691-11e8-9530-6c6f891fc3ad.jpg)
so how to use it to train image histogram ?