pytorch / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
https://pytorch.org
Other
82.12k stars 22.08k forks source link

Feature request: von Mises-Fisher distribution #13811

Open yang-song opened 5 years ago

yang-song commented 5 years ago

🚀 Feature

There should be a von Mises-Fisher distribution in torch.distributions.

Motivation

It is very important to have those directional distributions when you want to do research related to directional statistics for machine learning. For example, von Mises-Fisher will be very useful for modeling unit length vectors. See paper https://arxiv.org/pdf/1804.00891.pdf

Additional context

TensorFlow has the von Mises-Fisher distribution. https://github.com/tensorflow/tensorflow/issues/6141

Here is also an implementation of von Mises-Fisher in pytorch (using scipy, without GPU support) https://github.com/nicola-decao/s-vae-pytorch/tree/master/hyperspherical_vae/distributions

cc @vincentqb @fritzo @neerajprad @alicanb @vishwakftw

vishwakftw commented 5 years ago

cc: @alicanb

rachtsingh commented 5 years ago

cc @ahmadsalim and https://github.com/pyro-ppl/pyro/pull/1729

ahmadsalim commented 5 years ago

I will try to push it upstream when I have time, which hopefully is soon 😄

xqding commented 4 years ago

Hello, any progress on adding von Mises-Fisher distribution for higher dimension? Thanks.

ahmadsalim commented 4 years ago

@xqding I have a PR with some code in Pyro that you may reuse: https://github.com/pyro-ppl/pyro/pull/1745 . I had some issues with testing which I still have to resolve, but the distribution in the PR should work reasonably if you want to use it now 😄

xqding commented 4 years ago

@ahmadsalim Thanks. Does it work for high dimensional (> 5) von Mises-Fisher distribution? I read it a bit and it seems it only works on 3D. Or am I missing something?

ahmadsalim commented 4 years ago

It only works with 3D currently. I have not been working on higher dimensional cases, but they probably can be based of the same distribution with slight modification 😄

RylanSchaeffer commented 2 years ago

Is there an update on this issue? I found that tfp has this distribution implemented https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/VonMisesFisher#mean