-
Notifications
You must be signed in to change notification settings - Fork 750
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
add bincount api cn doc #3959
Merged
Merged
add bincount api cn doc #3959
Changes from all commits
Commits
Show all changes
3 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 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_tensor_bincount: | ||
|
||
bincount | ||
------------------------------- | ||
|
||
.. py:function:: paddle.bincount(x, weights=None, minlength=0, name=None): | ||
统计输入张量中每个元素出现的次数,如果传入weights张量则每次计数加一时会乘以weights张量对应的值 | ||
|
||
参数: | ||
:::::::::::: | ||
|
||
- **x** (Tensor) - 输入Tensor。必须是一维Tensor,其中元素必须大于等于0,数据类型为int32, int64。 | ||
- **weights** (Tensor, 可选) - weights Tensor,代表输入Tensor中每个元素的权重。长度必须与输入Tensor相同。数据类型为int32, int64, float32或float64。默认为None | ||
- **minlength** (int, 可选) - 输出Tensor的最小长度,如果大于输入Tensor的长度,则多出的位置补0。该值必须大于等于0。默认为0。 | ||
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. 少了name参数 |
||
- **name** (str,可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。 | ||
|
||
返回: | ||
:::::::::::: | ||
Tensor,维度为1。 | ||
|
||
代码示例: | ||
:::::::::::: | ||
|
||
.. code-block:: python | ||
import paddle | ||
x = paddle.to_tensor([1, 2, 1, 4, 5]) | ||
result1 = paddle.bincount(x) | ||
print(result1) # [0, 2, 1, 0, 1, 1] | ||
w = paddle.to_tensor([2.1, 0.4, 0.1, 0.5, 0.5]) | ||
result2 = paddle.bincount(x, weights=w) | ||
print(result2) # [0., 2.19999981, 0.40000001, 0., 0.50000000, 0.50000000] | ||
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.
Done