I am implementing the variational auto-encoder from this paper (Section 3.1): https://arxiv.org/pdf/2004.06271.pdf
My KL loss function is giving NaN values because some of my covariances are negative. Therefore, the log(covariance) in equation 3 is giving invalid outputs, as the log of a minus number is undefined.
How can I make my variational autoencoder only output positive numbers in its latent space?
Or, if doing so goes against the way neural networks are trained:
What can be done to adjust the KL loss function so that NaN values are not returned?