Closed miangangzhen closed 5 years ago
Wondering why using torch.log when apply KLDivLoss.
Your code:
loss_clust = gamma *criteria[1](torch.log(clusters), tar_dist) / batch
My code:
loss = criterion(y_hat_batch, torch.from_numpy(y_batch))
My code doesn't work, but yours did. I can't figure out what's torch.log role?
It is because PyTorch expects logprob as the input for KL loss. Check: link
Wondering why using torch.log when apply KLDivLoss.
Your code:
My code:
My code doesn't work, but yours did. I can't figure out what's torch.log role?