Skip to content
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.2] #6941

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/api/paddle/broadcast_tensors_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ broadcast_tensors

.. _Tensor 介绍: ../../guides/beginner/tensor_cn.html#id7

下图展示将三个 Tensor 广播到同一维度的过程。三个 Tensor 的尺寸分别为 [4, 1, 3]、[2, 3]、[4, 2, 1],在广播时,会从最后一个维度开始对齐,对于每一个维度,任意两个 Tensor 的在该维度大小相等;或者其中一个 Tensor 的维度等于 1;或者其中一个 Tensor 的维度不存在。在下图中,最后一个维度中,Tenser3 取值为 1,Tensor1 和 Tensor2 取值为 3,所有 Tensor 的该维度被扩张为3;倒数第二个维度中,Tenser1 取值为 2,Tensor2 和 Tensor3 取值为 2,所有 Tensor 的该维度被扩张为2;倒数第三个维度中,Tenser2 为空,Tensor1 和 Tensor3 取值为 4,所有 Tensor 的该维度被扩张为4。最终,所有 Tensor 都被扩张到 [4, 2, 3]。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文字可以稍微精简一下,可以直接说原shape是多少,广播后都成了多少,具某一维度的例子,具体细节参考 Tensor 的广播机制

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实,这段文字主要想表述,他们从后往前对齐,所以再删可能表达不清楚了。


.. figure:: ../../images/api_legend/broadcast.png
:width: 800
:alt: Broadcast图示
:align: center

Liyulingyue marked this conversation as resolved.
Show resolved Hide resolved

Liyulingyue marked this conversation as resolved.
Show resolved Hide resolved
参数
:::::::::
- input (list(Tensor)|tuple(Tensor)) - 一组输入 Tensor,数据类型为:bool、float32、float64、complex64、complex128、int32 或 int64。所有的输入 Tensor 均需要满足 rank <= 5。
Expand Down
Binary file added docs/images/api_legend/broadcast.png
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

张师傅怎么回事,tensor的图例是不是画错了? 广播后应该不会新增数据呀
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

会增加,会复制一份的。

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.