Giter VIP home page Giter VIP logo

generalized-lloyd-quantization's Introduction

generalized-lloyd-quantization

This is a pure Python/NumPy/SciPy implementation of the Generalized Lloyd quantization scheme, both in the most basic formulation[1][2] and also in a formulation which is optimal in terms of entropy rate[3][4]. The suboptimal version is often called the Linde Buzo Gray (LBG) algorithm and the optimal version is often called Entropy-Constrained Vector Quantization (ECVQ).

Important considerations

  1. These algorithms attempt to minimize a cost function that captures either just the mean-squared error of the quantization or both the MSE and the entropy of the resulting code. Keep in mind that this problem is non-convex and these algorithms only find a local minimum of these cost functions. In fact, the solution that is found may be heavily dependent on the initial locations of the assignment points.

  2. The LBG variant is only sensible when one intends to send each codeword with an equal and fixed number of bits, a so-called 'Fixed Length Code'. If the codewords can have a variable number of bits, a so-called 'Variable Length Code', then a lossless source code (e.g. Huffman or Arithmetic) will have an expected code length arbitrarily close to the entropy of the quantized code. In this setting you want to use the ECVQ variant, which will account for this entropy when making the codeword assignments.

  3. In the high-fidelity regime, where there are many assignment points, the rate-distortion benefit of using these algorithms may be minimal compared to a much simpler quantization using uniformly-spaced assignment points. The low-fidelity regime, with very few (carefully placed) assignment points, is where you should expect to see some benefit in using this approach.

At some point I may add an implementation in a GPU computing framework so that it can scale more easily for vector quantization in high dimensions, but for now this is an implementation that should still be usable for a reasonable number of dimensions.

Dependencies

Example

Usage can be inferred from the example found in the demo/ folder. In this particular case we generate samples of a 2D multivariate random variable. We can either quantize each coefficient separately or we can quantize the coefficients jointly. For this particular dataset it appears that not only are significant gains achieved by using the entropy-rate-optimal version of the algorithm, but that by quantizing the coefficients jointly, we also get a gain in coding efficiency.

alt text

Scalar Quantization alone

alt text

Vector Quantization alone

alt text

All six variants superimposed

alt text

Authors

Spencer Kent

References

[1]: Linde, Y., Buzo, A., & Gray, R. (1980). An algorithm for vector quantizer design. IEEE transactions on information theory, 28(1), 84-95.

[2]: Lloyd, S. (1982). Least squares quantization in PCM.
IEEE transactions on information theory, 28(2), 129-137.

[3]: Berger, T. (1982). Minimum entropy quantizers and permutation codes. IEEE transactions on information theory, 28(2), 149-157.

[4]: Chou, P. A., Lookabaugh, T., & Gray, R. M. (1989). Entropy-constrained vector quantization. IEEE transactions on acoustics, speech, and signal processing, 37(1), 31-42.

generalized-lloyd-quantization's People

Contributors

spencerkent avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.