obtain dynamic fixed point weight according .caffemodel file after fine-tune

34 views
Skip to first unread message

huagang...@gmail.com

unread,
Dec 4, 2018, 1:23:41 AM12/4/18
to ristretto-users
Hello, I want to use ristretto to quantify network parameters into typical data. I know that the network parameters that ristretto gets after the fine-tuning operation are floating-point data. So can I get the corresponding typical data by expanding the floating point parameters several times?
In fact, the parameter I extracted from the file (.caffemodel) is 0.24279352 (one of them), and the quantized.prototxt file shows that the corresponding number of decimal places is 3 (fl=3). Can I think 1.94283416 (0.24279352×8) which is fixed-point data corresponding to 0.24279352?
I still have a question. Why is the data extracted from caffemodel (after fine tuning) so accurate? If fl = 3, then the highest precision should be 0.125? Why do I extract data similar to 0.24279352?

ying.bu...@gmail.com

unread,
Dec 12, 2018, 9:25:04 AM12/12/18
to ristretto-users
I just provide my answers according to my knowledge.
1、 Quantization is just converting the origin floating point data to the new floating point data which is the same as the fixed point valued. For example, 1.23 can be quantized to 1.25 (if bw=8, fl=6 then get 01.010000 as the fixed point). I'm not clear the exact process  in the Ristretto,I guess it finds the nearest value under certain quantization params (bw and fl).
     So, Ristretto wouldn't generate a new caffemodel, just generate a new .prototxt. When you get the quantization params about a certain layer, you can calculate a lookup table, it contains all the floating points as the decimal representation of the fixed point. For example, the first conv layer weights have the bitwitdth 8,and fl 4, then the lookup table will get 256(or 255) numbers which are float points and convert from  binary fixed point 0000.0000 ~1111.1111. Using the lookup table ,you can get the nearest value to the origin float point.

2、As mentioned above, the data you extract from a fine-tuned model is exact a 32-bit caffemodel , you can get the corresponding value use the method I provided.
Reply all
Reply to author
Forward
0 new messages