Solved by zhl515 in post #9 
              
              
                You said you can’t obtain covariance matrix. In VAE paper, the author  assume the true (but intractable) posterior takes on a approximate Gaussian form with an approximately diagonal covariance. So just place  the std  on diagonal of convariance matrix, and other elements of matrix are zeros.