-
Notifications
You must be signed in to change notification settings - Fork 147
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added quantisation layer, commitment loss, and associated unit tests #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall good start. some questions / suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I like the way you structured the code, and adding the reshaping utils will come in handy as well.
Please include in the Test Plan:
|
Sorry I probably didn't make the purpose of Test Plan clear: You can just run tests related to your changes, e.g., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the nice work! Going through the threads in this PR I can see a few points to follow up:
- Learning of the codebook needs to be implemented by adding VQ loss or as moving average of the encoder output.
- Re-design of the commitment loss (or vqvae loss as a whole) and clean up API of the quantization layer.
Also I have a question for you:
- The commitment loss is computed with the quantized vectors detached before returned by
forward
as in OpenAI and the Google example. In you current implementation, the quantized vectors are detached after (insideCommitmentLoss
). Do you think the two steps are commutative?
Let me know your thoughts about those observation and if anything that might be missing.
Next step: click "import to fbsource" button below and wait for the internal CI to finish, fix any issues as needed.
I think as long as |
@RdoubleA has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@RdoubleA has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Summary:
Vector Quantized Variational Autoencoder (VQVAE) is widely used to generate multimodal data (audio, image, or video samples). A well-known model implementing this is OpenAI's DALL-E model, which can generate images from text captions. The core component of the VQVAE is the quantisation layer, which is a discrete embedding of vectors that codifies the outputs of an encoder. Here, this layer is implemented as its own module, along with commitment loss which is used to fine-tune the encoder.
Test plan:
Unit tests were created and added in this PR. Testing was done with PyTest.
pytest -vv test/modules/losses/test_commitment.py
pytest -vv test/modules/layers/test_quantisation.py