microsoft / LQ-Nets

LQ-Nets: Learned Quantization for Highly Accurate and Compact Deep Neural Networks
MIT License
239 stars 69 forks source link

Question about implementation (not bug) #9

Closed hnanhtuan closed 5 years ago

hnanhtuan commented 5 years ago

Hi,

Can you help to explain more about the code line 111-112 and 253? As I understand, these codes seem to work as the Straight-Through Estimator (STE)? However, I cannot understand how the output y is assigned to a new value but it is only affected in the backward pass? In the forward pass, y should still be quantized, right? Additionally, why do you use _tf.stop_gradient(-xclip) instead of _tf.stop_gradient(xclip) (the minus sign)? What is the difference here?

Thank you very much. Cheers,

hnanhtuan commented 5 years ago

Sorry for bothering you. I understand the code now.