Gumbel-Softmax: Difference between revisions
Created page with "Gumbel-softmax<ref name="jang2017gumbel"></ref> is a method to differentiably sample from a categorical distribution. It is available in PyTorch as [https://pytorch.org/docs/stable/generated/torch.nn.functional.gumbel_softmax.html torch.nn.functional.gumbel_softmax]. ==Background== Suppose we have some logits <math>\{a_i\}_{i=0}^{K}</math> (aka unnormalized log probabilities).<br> If we want convert this into a distribution, we can take the softmax.<br> However, there..." |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Gumbel-softmax<ref name="jang2017gumbel"></ref> is a method to differentiably sample from a categorical distribution. | Gumbel-softmax<ref name="jang2017gumbel"></ref><ref name="madison2017concrete"></ref> is a method to differentiably sample from a categorical distribution. | ||
It is available in PyTorch as [https://pytorch.org/docs/stable/generated/torch.nn.functional.gumbel_softmax.html torch.nn.functional.gumbel_softmax]. | It is available in PyTorch as [https://pytorch.org/docs/stable/generated/torch.nn.functional.gumbel_softmax.html torch.nn.functional.gumbel_softmax]. | ||
Line 5: | Line 5: | ||
==Background== | ==Background== | ||
Suppose we have some logits <math>\{a_i\}_{i=0}^{K}</math> (aka unnormalized log probabilities).<br> | Suppose we have some logits <math>\{a_i\}_{i=0}^{K}</math> (aka unnormalized log probabilities).<br> | ||
If we want convert this into a distribution, we can take the softmax.<br> | If we want convert this into a distribution to sample from, we can take the softmax.<br> | ||
However, there are scenarios where we may want to instead take a sample from the distribution and also backprop through it. | However, there are scenarios where we may want to instead take a sample from the distribution and also backprop through it. | ||
Line 12: | Line 12: | ||
# Add these to our logits. | # Add these to our logits. | ||
# Take the argmax. | # Take the argmax. | ||
The | The original advantage to this reparameterization trick is that you can precompute the i.i.d. values and then avoid expensive exponents when sampling at at runtime. | ||
However, by replacing the argmax with softmax, you get Gumbel-softmax which allows you to differentiate through the sampling procedure. | |||
==Misc== | ==Misc== | ||
Line 21: | Line 21: | ||
==Resources== | ==Resources== | ||
* [https://www.youtube.com/watch?v=JFgXEbgcT7g | * [https://www.youtube.com/watch?v=JFgXEbgcT7g Talk by Eric Jang] | ||
==References== | ==References== | ||
{{reflist|refs= | {{reflist|refs= | ||
<ref name="jang2017gumbel">Jang, E., Gu, S., & Poole, B. (2017). Categorical Reparameterization with Gumbel-Softmax. International Conference on Learning Representations. Retrieved from https:// | <ref name="jang2017gumbel">Jang, E., Gu, S., & Poole, B. (2017). Categorical Reparameterization with Gumbel-Softmax. International Conference on Learning Representations. Retrieved from https://arxiv.org/abs/1611.01144</ref> | ||
<ref name="madison2017concrete">Maddison, C. J., Mnih, A., & Teh, Y. W. (2017). The Concrete Distribution: A Continuous Relaxation of Discrete Random Variables. International Conference on Learning Representations. Retrieved from https://arxiv.org/abs/1611.00712</ref> | |||
}} | }} |