I thought torch.nn.functional.kl_div should compute KL divergence in Kullback–Leibler divergence - Wikipedia (the same as scipy.stats.entropy and tf.keras.losses.KLDivergence), but I cannot get the same results from a simple example. Does anyone know why?
 from scipy.stats import entropy
entropy([0.5,0.5],[0.7,0.3])
0.08717669357238891
kl_tf=tf.keras.losses.KLDivergence()
y_true=[0.5,0.5]
y_pred=[0.7,0.3]
kl_tf(y_true,y_pred)
<tf.Tensor: shape=(), dtype=float32, numpy=0.08717668>

Those two above gives the same kl divergence value. But when I tried to use torch.nn.functional.kl_div, the result is not the same.
y_true=[0.5,0.5]
y_pred=[0.7,0.3]
torch.nn.functional.kl_div(torch.FloatTensor(y_true),torch.FloatTensor(y_pred),reduction='sum')
tensor(-1.1109)