Skip to content

A Pytorch Implementations for Various Vector Quantization Methods

License

Notifications You must be signed in to change notification settings

GoGoDuck912/pytorch-vector-quantization

Repository files navigation

Pytorch Vector Quantization

A pytorch library for vector quantization methods. Vector quantization has been successfully used by high-quality image and audio generation, e.g., VQVAE, VQGAN.

Implemented methods:

  • Vector Quantization
  • Vector Quantization based on momentum moving average
  • Vector Quantization based on gumbel-softmax trick
  • Product Quantization
  • Residual Quantization

Usage

import torch
from vector_quantize import VectorQuantizer

vq = VectorQuantizer(
    n_e = 1024,          # codebook vocalbulary size
    e_dim = 256,         # codebook vocalbulary dimension
    beta = 1.0,          # the weight on the commitment loss
)

x = torch.randn(1, 256, 16, 16)          # size of NCHW
quantized, commit_loss, indices = vq(x)          # shape of (1, 256, 16, 16), (1), (1, 16, 16)

Releases

No releases published

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy