Skip to content

residual lfq #80

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

Merged
merged 12 commits into from
Oct 21, 2023
Merged

residual lfq #80

merged 12 commits into from
Oct 21, 2023

Conversation

lucidrains
Copy link
Owner

@lucidrains lucidrains commented Oct 18, 2023

aim would be integrate with soundstream in https://github.com/lucidrains/audiolm-pytorch if there is a signal

@lucidrains lucidrains marked this pull request as draft October 18, 2023 16:01
@lucidrains lucidrains marked this pull request as ready for review October 20, 2023 18:33
@lucidrains
Copy link
Owner Author

works

import torch
from vector_quantize_pytorch import ResidualLFQ

residual_lfq = ResidualLFQ(
    dim = 256,
    codebook_size = 256,
    num_quantizers = 2
)

x = torch.randn(1, 1024, 256)

residual_lfq.eval()

quantized, indices, commit_loss = residual_lfq(x)

quantized_out = residual_lfq.get_codes_from_indices(indices) 

assert torch.all(quantized == residual_lfq.project_out(quantized_out.sum(dim = 0)))

@lucidrains lucidrains mentioned this pull request Oct 20, 2023
2 tasks
@lucidrains lucidrains merged commit cd4fd3f into master Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants