hpi-xnor / BMXNet

(New version is out: https://github.com/hpi-xnor/BMXNet-v2) BMXNet: An Open-Source Binary Neural Network Implementation Based on MXNet
Apache License 2.0
350 stars 95 forks source link

Quantization method #50

Closed jacky4323 closed 6 years ago

jacky4323 commented 6 years ago

I confused that why using the function 2^k-1 Instead of 2^k

take 2.34669849e-01 for example:

  1. using 2^k-1 : weight_bit=2 the value is equal to 0.3333333,but actually 0.33 can't use two bits to represent
  2. using 2^k : weight_bit=2 the value is equal to 0.25, it can use two bits (0.11) to represent

So why don't use 2^k? Did I make a mistake? thanks.

image

yanghaojin commented 6 years ago

Hi Jacky, you can try some examples with k=1, input r_i belongs to [0, 1] as e.g., please try these 3 values for r_i: 0.1, 0.4, 1.0, to check how many possible values of quantize(r_i, k) could get for both options.

BTW, the quantization part of BMXNet is still not fully finished, we are still working on some issue in the backward pass. Hopefully, we could update the project in the next month. Best HJ

jacky4323 commented 6 years ago

I follow you're a suggestion to test,But If k larger than 1, it quantizes the vale using 2^k-1, and it can't be representable by k bits.

good news for update the project thanks!!

jacky4323 commented 6 years ago

sorry,it's my mistake