未验证 提交 da3de72d 编写于 作者: Z zhangbo9674 提交者: GitHub

[AMP] refine paddle.amp.decorate code example (#40159)

* refine amp.decorate code example

* refine code
上级 d30d85da
...@@ -107,9 +107,9 @@ def decorate(models, ...@@ -107,9 +107,9 @@ def decorate(models,
import paddle import paddle
model = paddle.nn.Conv2D(3, 2, 3, bias_attr=False) model = paddle.nn.Conv2D(3, 2, 3, bias_attr=False)
optimzier = paddle.optimizer.SGD(parameters=model.parameters()) optimizer = paddle.optimizer.SGD(parameters=model.parameters())
model, optimizer = paddle.amp.decorate(models=model, optimizers=optimzier, level='O2') model, optimizer = paddle.amp.decorate(models=model, optimizers=optimizer, level='O2')
data = paddle.rand([10, 3, 32, 32]) data = paddle.rand([10, 3, 32, 32])
...@@ -122,7 +122,7 @@ def decorate(models, ...@@ -122,7 +122,7 @@ def decorate(models,
model2 = paddle.nn.Conv2D(3, 2, 3, bias_attr=False) model2 = paddle.nn.Conv2D(3, 2, 3, bias_attr=False)
optimizer2 = paddle.optimizer.Adam(parameters=model2.parameters()) optimizer2 = paddle.optimizer.Adam(parameters=model2.parameters())
models, optimizers = paddle.amp.decorate(models=[model, model2], optimizers=[optimzier, optimizer2], level='O2') models, optimizers = paddle.amp.decorate(models=[model, model2], optimizers=[optimizer, optimizer2], level='O2')
data = paddle.rand([10, 3, 32, 32]) data = paddle.rand([10, 3, 32, 32])
......
...@@ -411,9 +411,9 @@ def amp_decorate(models, ...@@ -411,9 +411,9 @@ def amp_decorate(models,
import paddle import paddle
model = paddle.nn.Conv2D(3, 2, 3, bias_attr=False) model = paddle.nn.Conv2D(3, 2, 3, bias_attr=False)
optimzier = paddle.optimizer.SGD(parameters=model.parameters()) optimizer = paddle.optimizer.SGD(parameters=model.parameters())
model, optimizer = paddle.fluid.dygraph.amp_decorate(models=model, optimizers=optimzier, level='O2') model, optimizer = paddle.fluid.dygraph.amp_decorate(models=model, optimizers=optimizer, level='O2')
data = paddle.rand([10, 3, 32, 32]) data = paddle.rand([10, 3, 32, 32])
...@@ -426,7 +426,7 @@ def amp_decorate(models, ...@@ -426,7 +426,7 @@ def amp_decorate(models,
model2 = paddle.nn.Conv2D(3, 2, 3, bias_attr=False) model2 = paddle.nn.Conv2D(3, 2, 3, bias_attr=False)
optimizer2 = paddle.optimizer.Adam(parameters=model2.parameters()) optimizer2 = paddle.optimizer.Adam(parameters=model2.parameters())
models, optimizers = paddle.fluid.dygraph.amp_decorate(models=[model, model2], optimizers=[optimzier, optimizer2], level='O2') models, optimizers = paddle.fluid.dygraph.amp_decorate(models=[model, model2], optimizers=[optimizer, optimizer2], level='O2')
data = paddle.rand([10, 3, 32, 32]) data = paddle.rand([10, 3, 32, 32])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册