Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Histogramm loss func. #27

Closed
iperov opened this issue May 13, 2018 · 0 comments
Closed

Histogramm loss func. #27

iperov opened this issue May 13, 2018 · 0 comments

Comments

@iperov
Copy link

iperov commented May 13, 2018

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
python_2018-05-13_09-37-28

so how to use it to train image histogram ?

@iperov iperov closed this as completed May 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant