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

Add weighted random sampler #28545

Merged
merged 5 commits into from
Nov 16, 2020

Conversation

heavengate
Copy link
Contributor

@heavengate heavengate commented Nov 11, 2020

PR types

New features

PR changes

APIs

Describe

add paddle.io.WeightedRandomSampler
WeightedRandomSampler_en

@paddle-bot-old
Copy link

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

LielinJiang
LielinJiang previously approved these changes Nov 12, 2020
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Nov 12, 2020
@PaddlePaddle PaddlePaddle unlocked this conversation Nov 12, 2020
if isinstance(probs, (list, tuple)):
probs = np.array(probs)
assert isinstance(probs, np.ndarray), \
"probs should be paddle.Tensor, numpy.ndarray, list or tuple"
Copy link
Contributor

Choose a reason for hiding this comment

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

对用户的接口是用weights,报错信息和接口arg保持一致

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!


class WeightedRandomSampler(Sampler):
"""
Random sample with give weights (probabilities), sampe index will be in range
Copy link
Contributor

Choose a reason for hiding this comment

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

with give -> with given

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Nov 12, 2020
@PaddlePaddle PaddlePaddle unlocked this conversation Nov 12, 2020
saxon-zh
saxon-zh previously approved these changes Nov 12, 2020
Copy link

@saxon-zh saxon-zh left a comment

Choose a reason for hiding this comment

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

LGTM

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Nov 12, 2020
@PaddlePaddle PaddlePaddle unlocked this conversation Nov 12, 2020
@heavengate heavengate closed this Nov 14, 2020
@heavengate heavengate reopened this Nov 14, 2020
Copy link

@saxon-zh saxon-zh left a comment

Choose a reason for hiding this comment

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

LGTM

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

@heavengate heavengate merged commit ece1e4c into PaddlePaddle:develop Nov 16, 2020
@heavengate heavengate deleted the add_WeightedRandomSampler branch November 16, 2020 11:19
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.

5 participants