Skip to content

Commit 7bcee97

Browse files
Johannes Ballécopybara-github
authored andcommitted
Lower bounds the overflow bin by zero probability.
PiperOrigin-RevId: 323625009 Change-Id: I44f7c2f6120e492978eda252d5f981b21edf8a2d
1 parent fc0a33d commit 7bcee97

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tensorflow_compression/python/entropy_models/continuous_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def _build_tables(self, prior):
237237
def loop_body(args):
238238
prob, length = args
239239
prob = prob[:length]
240-
prob = tf.concat([prob, 1 - tf.reduce_sum(prob, keepdims=True)], axis=0)
240+
overflow = tf.math.maximum(1 - tf.reduce_sum(prob, keepdims=True), 0.)
241+
prob = tf.concat([prob, overflow], axis=0)
241242
cdf = range_coding_ops.pmf_to_quantized_cdf(
242243
prob, precision=self.range_coder_precision)
243244
return tf.pad(

0 commit comments

Comments
 (0)