itayhubara / BinaryNet.tf

BNN implementation in tensorflow
165 stars 54 forks source link

Can someone inform me why we need tf.clip_by_value(x,-1,1) before tf.sign(x) #8

Open Sibo-tao opened 6 years ago

Sibo-tao commented 6 years ago

I do not understand why there are two lines of codes in binarize(x): x=tf.clip_by_value(x,-1,1) return tf.sign(x)

because clipping will not change the sign of x. Why we need the first line?

jonkoi commented 6 years ago

I think it is the way to reinforce straight through estimator because tf.clip_by_value happens to zero out out gradients for x out of bound.

12baby21 commented 3 years ago

I have the same question. The tf.clip_by_value seems to be redundant before tf.sign.