pytorch, KL散度,reduction='batchmean'

在pytorch中计算KLDiv loss时,注意reduction='batchmean',不然loss不仅会在batch维度上取平均,还会在概率分布的维度上取平均。

参考:KL散度-相对熵