def loop_body(args): prob, length, tail = args prob = tf.concat([prob[:length], tail], axis=0) cdf = range_coding_ops.pmf_to_quantized_cdf( prob, precision=self.range_coder_precision) return tf.pad( cdf, [[0, max_length - length]], mode="CONSTANT", constant_values=0)
def loop_body(args): prob, length = args prob = prob[:length] prob = tf.concat([prob, 1 - tf.reduce_sum(prob, keepdims=True)], axis=0) cdf = range_coding_ops.pmf_to_quantized_cdf( prob, precision=self.range_coder_precision) return tf.pad( cdf, [[0, max_length - length]], mode="CONSTANT", constant_values=0)
def cdf_initializer(shape, dtype=None, partition_info=None): del shape, partition_info # unused assert dtype == tf.int32 fill = tf.constant(.5, dtype=self.dtype) prob = tf.fill((channels, 2), fill) cdf = range_coding_ops.pmf_to_quantized_cdf( prob, precision=self.range_coder_precision) return tf.placeholder_with_default(cdf, shape=(channels, None))