-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Docathon][Add API Legend No.55、22] add paddle.index_fill and paddle.shard_index API Paddle #70215
base: develop
Are you sure you want to change the base?
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
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介绍的下方
.. image:: ....
和上方文字空一行,否则无法渲染
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.
ci过不了,是否要重新提交一个pr
python/paddle/tensor/manipulation.py
Outdated
A two-dimensional tensor with a shape of [3, 3], through the index_fill operation, when axis = 0, the index tensor index is [0, 2], and the fill value value = -1, | ||
all elements in the first and third rows are filled with -1, thereby obtaining a new tensor with a shape still [3, 3] but some elements changed. A two-dimensional | ||
tensor with the shape [3, 3], by means of the index_fill operation, when axis = 0, the index tensor index is [0, 2], and the fill value value = -1, | ||
all the elements in the first and third rows are filled with -1, thus getting a new tensor with the same shape [3, 3] but some elements changed. |
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.
图例解释可以精简一些,如
A two-dimensional tensor with a shape of [3, 3], through the index_fill operation, when axis = 0, the index tensor index is [0, 2], and the fill value value = -1, | |
all elements in the first and third rows are filled with -1, thereby obtaining a new tensor with a shape still [3, 3] but some elements changed. A two-dimensional | |
tensor with the shape [3, 3], by means of the index_fill operation, when axis = 0, the index tensor index is [0, 2], and the fill value value = -1, | |
all the elements in the first and third rows are filled with -1, thus getting a new tensor with the same shape [3, 3] but some elements changed. | |
As shown below, a 2D tensor with shape [3, 3] is updated using the ``index_fill`` operation. With ``axis=0``, ``index=[0, 2]``, and ``value=-1``, the elements in the first and third rows are replaced with ``-1``. | |
The resulting tensor retains the same shape [3, 3], but with updated values. |
python/paddle/tensor/manipulation.py
Outdated
A two-dimensional tensor with a shape of [2, 1], through the shard_index operation, when index_num = 20, nshards = 2, and shard_id = 0, calculates | ||
the shard size shard_size = (20 + 2 - 1) // 2 = 10. For the element values in label, such as 16, because 16 >= 10 (not within the [0, 10) interval | ||
of shard 0), its value is set to ignore_value (i.e., -1) according to the formula; while the element value 1, since 0 <= 1 < 10 (within shard 0), | ||
the updated value is 1 - 0 * 10 = 1, and finally a new tensor with the same shape [2, 1] but some elements changed (such as shard_label) is obtained. |
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.
A two-dimensional tensor with a shape of [2, 1], through the shard_index operation, when index_num = 20, nshards = 2, and shard_id = 0, calculates | |
the shard size shard_size = (20 + 2 - 1) // 2 = 10. For the element values in label, such as 16, because 16 >= 10 (not within the [0, 10) interval | |
of shard 0), its value is set to ignore_value (i.e., -1) according to the formula; while the element value 1, since 0 <= 1 < 10 (within shard 0), | |
the updated value is 1 - 0 * 10 = 1, and finally a new tensor with the same shape [2, 1] but some elements changed (such as shard_label) is obtained. | |
As shown below, a 2D tensor with shape [2, 1] is updated using the ``shard_index`` operation. With ``index_num=20``, ``nshards=2``, and ``shard_id=0``, the shard size is calculated as ``shard_size = (20 + 2 - 1) // 2 = 10``. | |
For each element in label: If the value is within the shard range ``[0, 10)``, it is adjusted to its offset in the range. For example, ``1`` is updated to ``1 - 0 * 10 = 1``; Otherwise, it is set to the ``ignore_value`` (default ``-1``). For example, ``16`` is outside the range ``[0, 10)`` and becomes ``-1``. |
Sorry to inform you that dce184d's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
不需要重新提交,把 PR-CI-Codestyle-Check 流水线过了就行 |
PR Category
PR Types
Description