-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add regularizer #73
base: main
Are you sure you want to change the base?
add regularizer #73
Conversation
@@ -34,6 +35,7 @@ def __init__(self, model: nn.Module, config): | |||
self._run_simplifiers() | |||
self._convert2quantmodule() | |||
self._build_quantizer() | |||
self._build_regularizer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议成为quant_model的一部分, 而是由用户直接在main函数中调用
REGULARIZER: | ||
ENABLE: True | ||
TYPE: dampen | ||
LAMBDA: 0.01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议lambda作为quant_config一部分, 而是应该成为main.py parser的一部分
8bd7bbc
to
8397203
Compare
self.config = config | ||
|
||
def _get_loss(self, x, quantizer): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use black to reformat
scale = scale.detach() | ||
zero_point = zero_point.detach() | ||
|
||
min_val = (qmin - zero_point) * scale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use quant_drange api
https://github.com/megvii-research/Sparsebit/blob/main/sparsebit/quantization/quantizers/quant_tensor.py#L212
7189c8a
to
4c5ae67
Compare
|
cc: @PeiqinSun @Jiang-Stan