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

Probability distribution API of Beta and KL-Divergence #38558

Merged
merged 8 commits into from
Dec 31, 2021

Conversation

cxxly
Copy link
Contributor

@cxxly cxxly commented Dec 29, 2021

PR types

New features

PR changes

APIs

Describe

  • add Beta probability distribution, including mean, variance, sample, entropy, prob, log_prob method
  • add kl_divergence and register_kl API,and register implementation functions <Beta, Beta> <Dirichlet, Dirichlet> <ExponentialFamily, Exponentialfamily> <Normal, Normal> <Categorical, Categorical> <Uniform, Uniform>
  • fix some problems in add ExponentialFamily and Dirichlet probability distribution #38445

Examples

import paddle

# beta distribution
beta = paddle.distribution.Beta(alpha=0.5, beta=0.5)
print(beta.mean)

# kl divergence
p = paddle.distribution.Beta(alpha=0.5, beta=0.5)
q = paddle.distribution.Beta(alpha=0.3, beta=0.7)
print(paddle.distribution.kl_divergence(p, q))

# register kl
@paddle.distribution.register_kl(paddle.distribution.Beta, paddle.distribution.Beta)
def kl_beta_beta():
    pass # insert implementation here

@paddle-bot-old
Copy link

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

@cxxly cxxly force-pushed the beta-and-kl branch 2 times, most recently from 605793a to 00712e9 Compare December 30, 2021 03:03
iclementine
iclementine previously approved these changes Dec 30, 2021
Copy link

@iclementine iclementine 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

@jeff41404 jeff41404 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.

LG API

@iclementine iclementine merged commit 4794a44 into PaddlePaddle:develop Dec 31, 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.

5 participants