变分自动编码器中如何权衡KLD损耗与重构损耗
在我见过的VAE的几乎所有代码示例中,损失函数的定义如下(这是张量流代码,但是我看到theano,torch等类似。它也适用于卷积网络,但这也不太相关) ,仅影响轴的总和): # latent space loss. KL divergence between latent space distribution and unit gaussian, for each batch. # first half of eq 10. in https://arxiv.org/abs/1312.6114 kl_loss = -0.5 * tf.reduce_sum(1 + log_sigma_sq - tf.square(mu) - tf.exp(log_sigma_sq), axis=1) # reconstruction error, using pixel-wise L2 loss, for each batch rec_loss = …