Sine Skewed Toridial distribution#2826
Conversation
|
@fehiepsi, thanks for the review! 👍 |
…tributions/__init__.py`
…to feature/ss_dist
fehiepsi
left a comment
There was a problem hiding this comment.
Could you clarify the input shapes for base density and skewness? It is not clear to me what's the requirements so I couldn't check if the expand method and the reshape ops in sample and log_prob are valid.
|
Hi @fehiepsi, Thanks for the review! Sorry for the input dimensions being vague. Let me clarify; the requirements are ss = SineSkewed(base_dist=BaseDist(Size([3,3,2])).to_event(1), skewness=Size([3,3,2]))
assert ss.event_shape == (2,)
assert ss.batch_shape == (3,3)
ss1 = SineSkewed(base_dist=BaseDist(Size([3,3,2])).to_event(1), skewness=Size([3,3,2])).to_event(1)
assert ss1.event_shape == (3,2)
assert ss1.batch_shape == (3,)
ss2 = SineSkewed(base_dist=BaseDist(Size([3,3,2])).to_event(2), skewness=Size([3,3,2]))
assert ss2.event_shape == (3,2)
assert ss2.batch_shape == (3,)
try:
SineSkewed(base_dist=BaseDist(Size([3,3,2])).to_event(2), skewness=Size([3,3,2])).to_event(1)
assert 1==0
except AssertionError:
pass
try:
SineSkewed(base_dist=BaseDist(Size([3,3,2])).to_event(1), skewness=Size([3,3,2])).to_event(2)
assert 1==0
except AssertionError:
passI would like for the construction |
fehiepsi
left a comment
There was a problem hiding this comment.
Looks much cleaner than before. 👍
| psi_bound = 1 - skew_phi.abs() | ||
| skew_psi = pyro.sample('skew_psi', Uniform(-1., 1.)) | ||
| skewness = torch.stack((skew_phi, psi_bound * skew_psi), dim=-1) | ||
| assert skewness.shape == (num_mix_comp, 2) |
There was a problem hiding this comment.
It would be nice to have a constraint+transform for this (in a follow-up PR). I believe we can use signed stick-breaking transform here. This way users can define distributions over skewness (or just simply use pyro.param with correct constraint). Without that, it is a bit cumbersome for users to define correct skewness over general d-torus.
There was a problem hiding this comment.
With that, we can have correct constraints in the distribution definition. :D
There was a problem hiding this comment.
That would be neat; I'll add it to the backlog.
This PR introduces the Sine Skewed Toridial distribution described by Jose Ameijeiras-Alonso and Christophe Ley.
The distribution enables skewing a base distribution on a d-dimensional torus, which is useful, for example, with dihedral angles (1-torus) of peptides as can be seen on a Ramachandran plot.
Missing prior suggestion in docstring; inference method and inferable params as suggested in #2821.