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 Dirichlet distribution #5115

Merged
merged 6 commits into from Sep 20, 2018

Conversation

YoshikawaMasashi
Copy link
Contributor

split from #4678.

@YoshikawaMasashi
Copy link
Contributor Author

jenkins, test this please.

1 similar comment
@YoshikawaMasashi
Copy link
Contributor Author

jenkins, test this please.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit de38f99) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@YoshikawaMasashi
Copy link
Contributor Author

jenkins, test this please.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit 05c1ddf) succeeded without errors!

@toslunar toslunar self-assigned this Jul 26, 2018
@toslunar toslunar added the cat:feature Implementation that introduces new interfaces. label Jul 27, 2018
@YoshikawaMasashi
Copy link
Contributor Author

jenkins, test this please.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit ee1a1a1, target branch master) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@toslunar toslunar changed the title add dirichlet distribution Add Dirichlet distribution Aug 14, 2018
from chainer.functions.math import exponential
from chainer.functions.math import lgamma
from chainer.functions.math import sum as sum_mod
import numpy
Copy link
Member

Choose a reason for hiding this comment

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

Could you fix the import grouping?

@property
def entropy(self):
return sum_mod.sum(lgamma.lgamma(self.alpha), axis=-1) \
- lgamma.lgamma(self.alpha0) \
Copy link
Member

Choose a reason for hiding this comment

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

The multivariate log beta function (not necessarily a FunctionNode) could be useful in entropy, log_prob, and kl.

return self.__alpha

@property
def k(self):
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to encourage users to access this via event_shape, instead of providing the property k.

# Conflicts:
#	chainer/distributions/__init__.py
#	docs/source/reference/distributions.rst
#	tests/chainer_tests/distributions_tests/test_kldivergence.py
@YoshikawaMasashi
Copy link
Contributor Author

jenkins, test this please.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit c9f9516, target branch master) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

dist2 = self.make_dirichlet_dist()
self.check_kl(dist1, dist2)

@testing.with_requires('scipy')
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need scipy for the GPU test.

@@ -55,6 +55,12 @@ def make_categorical_dist(self, is_gpu=False):
params = self.encode_params({"p": p}, is_gpu)
return distributions.Categorical(**params)

def make_dirichlet_dist(self, is_gpu=False):
alpha = numpy.random.uniform(
1, 10, self.shape + (3,)).astype(numpy.float32)
Copy link
Member

Choose a reason for hiding this comment

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

Did you tried #5088 (comment) ?

Copy link
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

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

OK to merge this.

@toslunar toslunar merged commit fc99d9d into chainer:master Sep 20, 2018
@kmaehashi kmaehashi added this to the v5.0.0rc1 milestone Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:feature Implementation that introduces new interfaces.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants