
How to export INT8 quantized weight of deep neural network?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jisu Kwon
am 29 Mai 2024
Kommentiert: Angelo Yeo
am 30 Mai 2024
I trained neural network using Deep Learning Toolbox, and quantized it.
Below code is what I used to INT8 quantize network model.
% Create a dlquantizer object for quantization
quantObj = dlquantizer(net);
% quantOpts = dlquantizationOptions(target='host');
calibrate(quantObj,imdsTrain);
% valResults = validate(quantObj, imdsValidation, quantOpts);
% valResults.Statistics
% Perform quantization
quantObj = quantize(quantObj);
qDetailsQuantized = quantizationDetails(quantObj)
% Save the quantized network
save('quantizedNet.mat', 'quantObj');
exportONNXNetwork(quantObj,'quantizedNet.onnx')
After quantization, I got quantized network quantObj .
However, I cannot access weight and bias which coverted to INT8 format.
When I display quantized networks' weight and bias using bwloe code,
>> disp(quantObj.Layers(2).Bias(:,:,1))
-6.9011793e-12
It still shows float type value.
Even I tried to export network as ONNX, MATLAB shows below warning,
>> exportONNXNetwork(quantObj,'quantizedNet.onnx')
Warning: Exported weights are not quantized when exporting quantized networks.
How can I access INT8 quantized weight and bias value?
0 Kommentare
Akzeptierte Antwort
Angelo Yeo
am 30 Mai 2024
You should inspect your qDetailsQuantized which was extracted with quantizationDetails. Would you look up the qDetailsQuantized.QuantizedLearnables?
The following example can be helpful for you.

3 Kommentare
Angelo Yeo
am 30 Mai 2024
Yes, exactly. Thanks for the feedback. It's great to know it worked for you.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Quantization, Projection, and Pruning finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!