|View source on GitHub|
Computes distribution-dependent 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
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.