Hi everyone,
I am trying to learn a multivariate normal distribution. To simplify things, let’s say the input is fixed, and the labels are some 3d points (x, y, z).
My approach was to create a NN to output 9 values, corresponding to 3 means, 3 variances and 3 co-variances. Then at each step, do a rsample from a

MultivariateNormal(loc=m, covariance_matrix=c)

, with c being the symmetric covariance matrix created with the 6 variances and co-variances. Then I get the loss by comparing the “rsampled” 3d point, to a point from the labels.
However, I sometimes get an error at the creation of the distribution, because the covariance matrix is not always positive definite.

Is this the right approach ? Or is there a proper way to do this ?
If it is, how can I assure that the NN will produce valid distribution parameters ?
Should I use the other arguments (precision_matrix / scale_tril) instead of covariance_matrix at the creation of the distribution ? I don’t understand their mathematical meanings …

Thank you,
PL