What is the difference between the various KL-divergence implementations in TensorFlow?

36 views Asked by At

While constructing a Variational Autoencoder in TensorFlow, I came across various implementations of Kullback–Leibler divergence:

  1. tfp.distributions.kl_divergence, which implements the exact KL-divergence measure.
  2. tfp.layers.KLDivergenceAddLoss, which uses a Monte Carlo approximation.
  3. tfp.layers.KLDivergenceRegularizer, which seems similar in calculation and use.
  4. tf.keras.losses.KLDivergence, which uses the formula y_true * log(y_true / y_pred).

I use tfp.distributions to model both the prior and the posterior, so any of the above implementations are compatible. However, although I assume that (2) and (3) are identical, I primarily wonder whether these are comparable to (4).

Any knowledge on this matter is appreciated!

0

There are 0 answers