未验证 提交 96ff6103 编写于 作者: Z zhangjingwei 提交者: GitHub

修改COPY-FROM add_example_for_lazygurd (#55411)

* add_example_for_lazygurd

* fix
上级 3624723f
...@@ -93,6 +93,21 @@ class LazyGuard: ...@@ -93,6 +93,21 @@ class LazyGuard:
LazyGuard is a wrapper interface for nn.Layer, it forwards the construct LazyGuard is a wrapper interface for nn.Layer, it forwards the construct
process of user defined Layer. Meanwhile, it provides necessary API to process of user defined Layer. Meanwhile, it provides necessary API to
trigger EagerParamBase Lazy Initialization and get startup Program. trigger EagerParamBase Lazy Initialization and get startup Program.
Examples:
.. code-block:: python
from paddle import LazyGuard
from paddle.nn import Linear
with LazyGuard():
# w and b are initialized lazily and have no memory.
net = Linear(10, 10)
for param in net.parameters():
# Initialize param and allocate memory explicitly.
param.initialize()
""" """
def __enter__(self): def __enter__(self):
......
...@@ -2851,6 +2851,7 @@ def scatter(x, index, updates, overwrite=True, name=None): ...@@ -2851,6 +2851,7 @@ def scatter(x, index, updates, overwrite=True, name=None):
Output is obtained by updating the input on selected indices based on updates. Output is obtained by updating the input on selected indices based on updates.
.. code-block:: python .. code-block:: python
:name: code-example1
import paddle import paddle
#input: #input:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册