GithubHelp home page GithubHelp logo

mrusci / training-mixed-precision-quantized-networks Goto Github PK

View Code? Open in Web Editor NEW
46.0 2.0 14.0 31 KB

This repository containts the pytorch scripts to train mixed-precision networks for microcontroller deployment, based on the memory contraints of the target device.

Python 97.39% Shell 2.61%
mixed-precision-training qnn edge-ai quantized-neural-networks integer-arithmetic low-power-mcu pytorch

training-mixed-precision-quantized-networks's People

Contributors

mrusci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

training-mixed-precision-quantized-networks's Issues

Clamping Inside Quantization Function

Hi,
The asymmetric quantization function used in the code is not clamping the data tensor for which the values exceed the specified bit width. For 4-bit quantization, the deployment model contains values (weights) that exceed the 4-bit range.
Is there any problem if I clamp the data tensor before converting it back to floating-point on the accuracy?
If it is, then what could be the solution?

Thanks

Error in Quick start

Hi
Firstly, I appreciate you for this project. It seems you haven't updated your code since four years ago. Some errors occur for

python3 main_binary.py -a mobilenet --mobilenet_width 1.0 --mobilenet_input 224 --save Imagenet/mobilenet_224_1.0_w8a8 --dataset imagenet --type_quant 'PerLayerAsymPACT' --weight_bits 8 --activ_bits 8 --activ_type learned --gpus 0,1,2,3 -j 8 --epochs 12 -b 128 --save_check --quantizer --batch_fold_delay 1 --batch_fold_type folding_weights

I solved some of them by using

  • transforms.Resize instead of transforms.Scale
  • reader = tf.train.load_checkpoint(tensorflow_model) instead of reader = pywrap_tensorflow.NewCheckpointReader(tensorflow_model)
  • correct_k = correct[:k].reshape(-1).float().sum(0) instead of correct_k = correct[:k].view(-1).float().sum(0)

I got stucked at this error:

Traceback (most recent call last):
  File "/content/training-mixed-precision-quantized-networks/main_binary.py", line 456, in <module>
    main()
  File "/content/training-mixed-precision-quantized-networks/main_binary.py", line 286, in main
    train_loss, train_prec1, train_prec5 = train(
  File "/content/training-mixed-precision-quantized-networks/main_binary.py", line 443, in train
    return forward(data_loader, model, criterion, epoch,
  File "/content/training-mixed-precision-quantized-networks/main_binary.py", line 411, in forward
    quantizer.backprop_quant_gradients()    
  File "/content/training-mixed-precision-quantized-networks/quantization/quantop.py", line 1037, in backprop_quant_gradients
    w_max_param.grad.data = grad_a_max
AttributeError: 'NoneType' object has no attribute 'data'

Can you take a look at it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.