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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dirichlet Multinomial to PyTorch Distributions #56030

Open
RylanSchaeffer opened this issue Apr 14, 2021 · 3 comments
Open

Add Dirichlet Multinomial to PyTorch Distributions #56030

RylanSchaeffer opened this issue Apr 14, 2021 · 3 comments
Labels
function request A request for a new function or the addition of new arguments/modes to an existing function. module: distributions Related to torch.distributions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@RylanSchaeffer
Copy link

RylanSchaeffer commented Apr 14, 2021

馃殌 Feature

The Dirichlet-Multinomial distribution is something I need for my research. TensorFlow has this distribution implemented (https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/DirichletMultinomial). Can someone please implement this distribution in PyTorch, or point me towards how I might implement it myself?

Motivation

Common probabilistic language models (e.g. mixtures of unigrams) require using Dirichlet-Multinomial distributions.

Pitch

Add the distribution to Pytorch. That is, there should be a distribution torch.distributions.dirichlet.DirichletMultinomial.

cc @fritzo @neerajprad @alicanb @vishwakftw @nikitaved

@mruberry mruberry added function request A request for a new function or the addition of new arguments/modes to an existing function. module: distributions Related to torch.distributions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Apr 15, 2021
@fritzo
Copy link
Collaborator

fritzo commented Apr 15, 2021

@RylanSchaeffer we have a PyTorch implementation in Pyro, including a sparse optimization (code, docs)

from pyro.distributions import DirichletMultinomial

You can use this directly or move it upstream to PyTorch.

@RylanSchaeffer
Copy link
Author

RylanSchaeffer commented Apr 16, 2021

@fritzo , thanks! That might suffice. As a principle, what determines whether something makes it from Pyro to PyTorch?

@fritzo
Copy link
Collaborator

fritzo commented Apr 16, 2021

what determines whether something makes it from Pyro to PyTorch?

Informally we have moved distributions from Pyro to PyTorch if:

  1. there appears to be public demand for the distribution,
  2. the distribution's interface is stable,
  3. the distribution's implementation is uncontroversial (e.g. does not use unsafe hacks),
  4. someone has the motivation and time to migrate code, update docs, and write tests.

I think DirichletMultinomial already satisfies 1-3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
function request A request for a new function or the addition of new arguments/modes to an existing function. module: distributions Related to torch.distributions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants