Skip to content

Conversation

ooooo-create
Copy link
Contributor

@paddle-bot
Copy link

paddle-bot bot commented Aug 28, 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 the contributor External developers label Aug 28, 2023
@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Aug 29, 2023
>>> # Need to set excluded layers before calling decorate
>>> paddle.incubate.asp.set_excluded_layers([my_layer.linear1.full_name()])

>>> optimizer = paddle.incubate.asp.decorate(optimizer)
Copy link
Contributor

Choose a reason for hiding this comment

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

to @megemini :自己记录一下 ~ 下面一段程序:

In [1]:                 >>> import paddle
   ...:                 >>> class MyLayer(paddle.nn.Layer):
   ...:                 ...     def __init__(self):
   ...:                 ...         super().__init__()
   ...:                 ...         self.linear1 = paddle.nn.Linear(4624, 100)
   ...:                 ...
   ...:                 ...     def forward(self, img):
   ...:                 ...         prediction = self.linear1(img)
   ...:                 ...         return prediction
   ...:                 >>> my_layer = MyLayer()
   ...:                 >>> optimizer = paddle.optimizer.SGD(
   ...:                 ...     learning_rate=0.01, parameters=my_layer.parameters())
   ...:                 >>> optimizer = paddle.incubate.asp.decorate(optimizer)
W0829 13:57:09.095414 11450 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 11.2, Runtime API Version: 11.6
W0829 13:57:09.102089 11450 gpu_resources.cc:149] device: 0, cuDNN Version: 8.4.

In [2]: optimizer.state_dict()
Out[2]: 
{'linear_0.w_0.asp_mask': Parameter containing:
 Tensor(shape=[4624, 100], dtype=float32, place=Place(gpu:0), stop_gradient=True,
        [[1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         ...,
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.]])}

In [3]:                 >>> my_layer = MyLayer()
   ...:                 >>> optimizer = paddle.optimizer.SGD(
   ...:                 ...     learning_rate=0.01, parameters=my_layer.parameters())
   ...:                 >>> optimizer = paddle.incubate.asp.decorate(optimizer)

In [4]: optimizer.state_dict()
Out[4]: 
{'linear_0.w_0.asp_mask': Parameter containing:
 Tensor(shape=[4624, 100], dtype=float32, place=Place(gpu:0), stop_gradient=True,
        [[1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         ...,
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.]]),
 'linear_1.w_0.asp_mask': Parameter containing:
 Tensor(shape=[4624, 100], dtype=float32, place=Place(gpu:0), stop_gradient=True,
        [[1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         ...,
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.],
         [1., 1., 1., ..., 1., 1., 1.]])}

In [5]: 

由于之前提到的 layer 全局名称的问题,这里的 optimizer 会累计参数 ~

也不清楚这样有没有影响?(至少 save 的文件大小有影响 ... ...)

Copy link
Contributor

@megemini megemini left a comment

Choose a reason for hiding this comment

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

LGTM ~ @SigureMo 再确认一下?~

另外,asp 木有中文文档 ~

英文:
image

中文:
image

@sunzhongkai588

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 1c85859 into PaddlePaddle:develop Aug 30, 2023
@sunzhongkai588
Copy link
Contributor

另外,asp 木有中文文档 ~

@mingxu1067 是否可以补充一下~

@ooooo-create ooooo-create deleted the ooooo/xdoctest201 branch August 31, 2023 10:18
BeingGod pushed a commit to BeingGod/Paddle that referenced this pull request Sep 9, 2023
…on/paddle/incubate/asp/asp.py` (PaddlePaddle#56731)

* [Doctest]fix No.239, test=docs_preview

* fix style
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.

5 participants