Skip to content

Conversation

ZHUI
Copy link
Collaborator

@ZHUI ZHUI commented Sep 15, 2021

PR types

New features

PR changes

APIs

Describe

Add segment apis to paddle.incubate

Segment APIs provide operations (sum, mean, max, min) on certain segment part. Following image demonstrates the process of segment mean. The segment_ids divides the data into 4 parts, and segment_mean calculates the mean of each part.

data = paddle.to_tensor([5.0,1,7,2,3,4,1,3])
segment_ids = paddle.to_tensor([0,0,0,1,2,2,3,3], dtype="int32")
paddle.incubate.segment_mean(data, segment_ids)
# [4.33333349, 2.        , 3.50000000, 2.        ]

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.


This operator calculate the maximum elements of input `data` which with
the same index in `segment_ids`.
It computes a tensor such that $out_i = \\min_{j} data_{j}$
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

\max

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

# limitations under the License.

__all__ = [
'segment_sum',
Copy link
Contributor

Choose a reason for hiding this comment

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

这里不用加到__all__列表,这个列表会用来统计公开API,只需要在目标位置加一次就行。

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

下个PR进行修复 : #35818

@ZHUI ZHUI merged commit 4b68388 into PaddlePaddle:develop Sep 16, 2021
@ZHUI ZHUI deleted the add_segment_api branch September 17, 2021 06:17
AnnaTrainingG pushed a commit to AnnaTrainingG/Paddle that referenced this pull request Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants