-
Notifications
You must be signed in to change notification settings - Fork 823
add static_pylayer api cn docs #6167
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
Merged
sunzhongkai588
merged 4 commits into
PaddlePaddle:develop
from
MarioLulab:luqi/add_static_pylayer
Sep 13, 2023
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.. _cn_api_fluid_layers_static_pylayer: | ||
|
||
static_pylayer | ||
------------------------------- | ||
|
||
|
||
.. py:function:: paddle.static.nn.static_pylayer(forward_fn, inputs, backward_fn=None, name=None) | ||
|
||
|
||
该 API 返回 ``forward_fn(inputs)``,并且根据传入的 ``forward_fn`` 和 ``backward_fn`` 的执行逻辑创建两个 sub_block, | ||
同时创建 ``pylayer`` 算子,``pylayer`` 算子的属性储存创建的 sub_block ID。 | ||
|
||
``forward_fn`` 和 ``backward_fn`` 需要返回同样嵌套结构(nest structure)的 Tensor。 | ||
PaddlePaddle 里 Tensor 的嵌套结构是指一个 Tensor,或者 Tensor 的元组(tuple),或者 Tensor 的列表(list)。 | ||
|
||
.. note:: | ||
1. 如果 ``backward_fn`` 被设置为 None,用户需要使 ``forward_fn`` 的输入数量和 ``backward_fn`` 的输出数量相同,``forward_fn`` 的输出数量和 ``backward_fn`` 的输入数量相同。 | ||
2. 在 ``backward_fn`` 被设置为 ``None`` 的情况下,``inputs`` 里所有 Variable 的 ``stop_gradient`` 属性应该被设为 ``True``,否则可能会在反向传播(backward propagation)中得到意想不到的结果。 | ||
3. 本 API 只能被运行在静态图模式下。 | ||
|
||
参数 | ||
::::::::: | ||
- **forward_fn** (callable) - 一个前向传播(forward propagation)时被调用的 callable。 | ||
- **inputs** (list[Variable]) - Variable 类型列表,其含义为 ``forward_fn`` 的输入 Variable。 | ||
- **backward_fn** (callable,可选) - 一个反向传播(backward propagation)时被调用的 callable。默认值:``None``,表示不需要进行反向传播(backward propagation)。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值:``None``。 | ||
|
||
返回 | ||
::::::::: | ||
Variable|list(Variable)|tuple(Variable),该 API 返回 ``forward_fn(inputs)``。 | ||
|
||
代码示例 | ||
::::::::: | ||
COPY-FROM: paddle.static.nn.static_pylayer |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
标签改一下叭,就按api路径同步
.. _cn_api_paddle_static_nn_static_pylayer:
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.
已修改