ricky40403 / dsq Goto Github PK
View Code? Open in Web Editor NEWpytorch implementation of "Differentiable Soft Quantization: Bridging Full-Precision and Low-Bit Neural Networks"
pytorch implementation of "Differentiable Soft Quantization: Bridging Full-Precision and Low-Bit Neural Networks"
Hi, thank you for your implementation!
I use the CIFAR10 dataset for quick training and evaluation on the 8-bit setting, but I only got not more than 80%@top1 accuracies with/without activation quantization. Could you give me any clue of why this happens? The learning rate is decreased by 10x every 30 epochs. But the accuracy stops increasing after around 40-50 epochs.
Thanks for your attention!
Hi, impressive work!
I want to reproduce the results of this implementation.
Could you share the trained quantization model files (model_best.pth.tar)?
Thanks!
Very appreciate for your implementation.
"RuntimeError: derivative for floor_divide is not implemented"
I have encounter this problem when i try to transform the conv layer to DSQ conv ,
and I can't find this function implement anywhere in the code.
Would you please tell me how to solve the above problem?
Thank you very much.
Hi.
In the code, function "set_quanbit()" is used to set the quantization bit for weights. However, in function "set_quanbit()", only attribute "num_bit" is modified, while attribute "bit_range" is left unchanged.
def set_quanbit(model, quan_bit = 8): for module_name in model._modules: if len(model._modules[module_name]._modules) > 0: set_quanbit(model._modules[module_name], quan_bit) else: if hasattr(model._modules[module_name], "num_bit"): setattr(model._modules[module_name], "num_bit", quan_bit) return model
Because the default initialized value of attribute "num_bit" in class "DSQConv" is 8, the attribute "bit_range" will be initialized when the "num_bit" is 8, but the attribute "bit_range" is not modified when "num_bit" is changed. This means that when we set quant_bit other than 8, the weights will not quantize correctly.
class DSQConv(nn.Conv2d): def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, momentum = 0.1, num_bit = 8, QInput = True, bSetQ = True):
To fix this bug, I recommend reset attribute "bit_range" as well in function "set_quanbit()".
Hi, thanks for sharing this great implementation. I wonder if you have ever evaluated the module you wrote, does it performs same with the paper's performance?
@ricky40403
Hey, thanks for your great work. When i read the paper and your code, i have three question:
tested in 4 bit with res18 on imagenet
, can you release the evaluate code. Have you implement the low-bits GEMM by the MLA instruction on ARM NEON?@ricky40403
Thanks for your hard and great work.
I copied the DSQConv.py into my project and used DSQConv instead of nn.conv2d except the first and the last layers. However during the training process, after several iterations I found that the value of alphaW is less than zero. It further caused the value of k is Nna. I used 0.5 as initial value of alphaW and set the initial learning rate to 0.001.
Would you please tell me the possible reasons of the above problem?
Thank you very much.
when I use distributed init_method is tcp
Hello. First of all, congratulation on your work. I would like to reproduce your work but I am facing a strange problem. When trying to use your DSQConv layer, I get the following error:
"torch.nn.modules.module.ModuleAttributeError: 'DSQConv' object has no attribute 'running_lw'"
Changing register_buffer for simple attribute assignment did not fix it. Can you reproduce the problem or help me in any way?
I would also like to ask you how can I store the models in an encoded way to compare the storage savings of lower bit range solutions.
Thank you in advance.
from PyTransformer.transformers.quantize import QConv2d, QuantConv2d, QLinear, ReLUQuant
ImportError: cannot import name 'QuantConv2d'
the 'QuantConv2d' function is not in the file .
Is there a problem with the code?thinks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.