tfc.distributions.quantization_offset

View source on GitHub

Computes distribution-dependent quantization offset.

View aliases

Main aliases

tfc.quantization_offset

tfc.distributions.quantization_offset(
 distribution
)

For range coding of continuous random variables, the values need to be quantized first. Typically, it is beneficial for compression performance to align the centers of the quantization bins such that one of them coincides with the mode of the distribution. With offset being the mode of the distribution, for instance, this can be achieved simply by computing:

x_hat = tf.round(x - offset) + offset

This method tries to determine the offset in a best-effort fashion, based on which statistics the Distribution implements. First, a method self._quantization_offset() is tried. If that isn't defined, it tries in turn: self.mode(), self.quantile(.5), then self.mean(). If none of these are implemented, it falls back on quantizing to integer values (i.e., an offset of zero).

Note the offset is always in the range [-.5, .5] as it is assumed to be combined with a round quantizer.

Args

distribution A tfp.distributions.Distribution object.

Returns

A tf.Tensor broadcastable to shape self.batch_shape, containing the determined quantization offsets. No gradients are allowed to flow through the return value.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.

Last updated 2024年04月26日 UTC.