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
【PaddlePaddle Hackathon 2】18、为 Paddle 新增 paddle.heaviside 和 paddle.Tensor.heaviside API #4641
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
acb2bee
Create heaviside_cn.rst
BrilliantYuKaimin 1634bd7
add heaviside
BrilliantYuKaimin 5cd3393
Update heaviside_cn.rst
BrilliantYuKaimin 7355228
Update Tensor_cn.rst
TCChenlong 37fda16
Merge branch 'PaddlePaddle:develop' into heaviside
BrilliantYuKaimin 3da57cb
Update Tensor_cn.rst
TCChenlong 2684c34
Update Tensor_cn.rst
TCChenlong 4b8a47c
Update heaviside_cn.rst
BrilliantYuKaimin 69bcd75
add heaviside in overview
BrilliantYuKaimin bc43b50
Update heaviside_cn.rst
BrilliantYuKaimin File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,37 @@ | ||
.. _cn_api_paddle_tensor_heaviside: | ||
|
||
heaviside | ||
------------------------------- | ||
|
||
.. py:function:: paddle.heaviside(x, y, name=None) | ||
逐元素地对 Tensor `x` 计算由 Tensor `y` 中的对应元素决定的赫维赛德阶跃函数,其计算公式为 | ||
|
||
.. math:: | ||
\mathrm{heaviside}(x, y)= | ||
\left\{ | ||
\begin{array}{lcl} | ||
0,& &\text{if } \ x < 0, \\ | ||
y,& &\text{if } \ x = 0, \\ | ||
1,& &\text{if } \ x > 0. | ||
\end{array} | ||
\right. | ||
.. note:: | ||
``paddle.heaviside`` 遵守广播机制,如您想了解更多,请参见 :ref:`cn_user_guide_broadcasting`。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 历史问题,描述有误,请 @TCChenlong 统一做修改:
|
||
|
||
参数 | ||
::::::::: | ||
- **x** (Tensor)- 赫维赛德阶跃函数的输入 Tensor。数据类型为 float32、float64、int32 或 int64。 | ||
- **y** (Tensor)- 决定了一个赫维赛德阶跃函数的 Tensor。数据类型为 float32、float64、int32 或 int64。 | ||
- **name** (str,可选)- 操作的名称(可选,默认值为 None)。更多信息请参见 :ref:`api_guide_Name`。 | ||
|
||
返回 | ||
::::::::: | ||
`Tensor`,存储运算后的结果。如果 `x` 和 `y` 有不同的形状且是可以广播的,那么返回 Tensor 的形状是 `x` 和 `y` 经过广播后的形状。如果 `x` 和 `y` 有相同的形状,那么返回 Tensor 的形状与 `x` 和 `y` 相同。 | ||
|
||
|
||
代码示例 | ||
:::::::::: | ||
COPY-FROM: paddle.heaviside:heaviside-example |
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.
返回类型需要写到返回里面
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.
我看别的全都是这么写的呀。那具体地改成什么呢?
返回,Tensor,计算后的Tensor
吗?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.
这个文件比较特殊,可以先这样写