I have taken the following piece of code from the OpenAI code of GitHub from the following link:
def discretized_logistic(mean, logscale, binsize=1 / 256.0, sample=None):
scale = tf.exp(logscale)
sample = (tf.floor(sample / binsize) * binsize - mean) / scale
logp = tf.log(tf.sigmoid(sample + binsize / scale) - tf.sigmoid(sample) + 1e-7)
return tf.reduce_sum(logp, [1, 2, 3])
I am unable to understand mathematical intuition or explanation of the above code. Even, I am unable to find the reference for this. Could you please explain?