Skip to content
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

[xdoctest][task 121] Reformat example code with google style in python/paddle/quantization/ptq.py #56232

Merged
merged 3 commits into from
Aug 21, 2023

Conversation

Candy2Tang
Copy link
Contributor

@Candy2Tang Candy2Tang commented Aug 13, 2023

PR types

Others

PR changes

Docs

Description

对应tracking issue: #55629
预览链接:

  • en: 生成中...
  • zh: 生成中...

@paddle-bot
Copy link

paddle-bot bot commented Aug 13, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Aug 13, 2023
@paddle-bot
Copy link

paddle-bot bot commented Aug 13, 2023

✅ This PR's description meets the template requirements!
Please wait for other CI results.

@Candy2Tang Candy2Tang changed the title [xdoctest][task 121] test=docs_preview [xdoctest][task 121] Reformat example code with google style in python/paddle/quantization/ptq.py Aug 13, 2023
@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Aug 14, 2023
Comment on lines 56 to 110
.. code-block:: python
from paddle.quantization import PTQ, QuantConfig
from paddle.quantization.observers import AbsmaxObserver
from paddle.vision.models import LeNet

observer = AbsmaxObserver()
q_config = QuantConfig(activation=observer, weight=observer)
ptq = PTQ(q_config)
model = LeNet()
model.eval()
quant_model = ptq.quantize(model)
print(quant_model)
>>> from paddle.quantization import PTQ, QuantConfig
>>> from paddle.quantization.observers import AbsmaxObserver
>>> from paddle.vision.models import LeNet

>>> observer = AbsmaxObserver()
>>> q_config = QuantConfig(activation=observer, weight=observer)
>>> ptq = PTQ(q_config)
>>> model = LeNet()
>>> model.eval()
>>> quant_model = ptq.quantize(model)
>>> print(quant_model)
LeNet(
(features): Sequential(
(0): QuantedConv2D(
(weight_quanter): AbsmaxObserverLayer()
(activation_quanter): AbsmaxObserverLayer()
)
(1): ObserveWrapper(
(_observer): AbsmaxObserverLayer()
(_observed): ReLU()
)
(2): ObserveWrapper(
(_observer): AbsmaxObserverLayer()
(_observed): MaxPool2D(kernel_size=2, stride=2, padding=0)
)
(3): QuantedConv2D(
(weight_quanter): AbsmaxObserverLayer()
(activation_quanter): AbsmaxObserverLayer()
)
(4): ObserveWrapper(
(_observer): AbsmaxObserverLayer()
(_observed): ReLU()
)
(5): ObserveWrapper(
(_observer): AbsmaxObserverLayer()
(_observed): MaxPool2D(kernel_size=2, stride=2, padding=0)
)
)
(fc): Sequential(
(0): QuantedLinear(
(weight_quanter): AbsmaxObserverLayer()
(activation_quanter): AbsmaxObserverLayer()
)
(1): QuantedLinear(
(weight_quanter): AbsmaxObserverLayer()
(activation_quanter): AbsmaxObserverLayer()
)
(2): QuantedLinear(
(weight_quanter): AbsmaxObserverLayer()
(activation_quanter): AbsmaxObserverLayer()
)
)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整体缩进层级 +1 吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,已修改~~

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@luotao1 luotao1 merged commit b39f5f6 into PaddlePaddle:develop Aug 21, 2023
BeingGod pushed a commit to BeingGod/Paddle that referenced this pull request Sep 9, 2023
…n/paddle/quantization/ptq.py (PaddlePaddle#56232)

* [xdoctest][task 121] test=docs_preview

* test=document_fix

* fix indent

---------

Co-authored-by: SigureMo <sigure.qaq@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants