Closed PengEC17 closed 4 months ago
在pytorch官方KLDivLoss损失函数的描述文档中有提到,To avoid underflow issues when computing this quantity, this loss expects the argument input in the log-space. The argument target may also be provided in the log-space if log_target= True.
所以代码中可以对网络输出使用LogSoftMax()作为KLDivLoss的input。并且,由于 log_target默认为False,所以真值用SoftMax()表示也没有问题。
我发现真值使用的是高斯分布,但是在损失函数中计算KL散度的时候预测值使用的是LogSoftmax。为什么不用和真值一样的分布?