lucidrains / lucidrains/vector-quantize-pytorch
Gumbel max trick does not seem to make sense in here
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4k
- Forks
- 338
- PR merge metrics
- No merged PRs in 30d
Description
Hi all,
I want to ask a question regarding some concerns I got looking at the usage of the gumbel_sample method when reinmax=False.
First, this sampling technique is mathematically equivalent to sample from the categorical distribution, Gumbel is doing nothing here (just sampling), and the argmax makes the operation non differentiable (I know we apply STE later).
Additionally, the logits are the codebook distances (dist in the first snippet above). It's an always positive variable, which means that it's going to be biased because it's bounded at zero. There are no gradients flowing from the sampling operation backwards (because it is not a Gumbel softmax, but a Gumbel max) hence the logits magnitude never gets altered to improve the sampling.
It seems to me that this is just takes a hidden variable (the distance matrix) normalizes it given an arbitrary temperature parameter and samples from it, adding biased noise to the straight-through relaxation... What am I missing?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vector_quantize_pytorch/vector_quantize_pytorch.py at the referenced lines 472 and 72-77, then compare the gumbel_sample usage with the linked Gumbel-max explanation. Determine whether the distance-based logits and straight-through path are intentional; done requires resolving the mathematical concern and documenting or correcting the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100