Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Add a small amount times the identity matrix to prevent errors
- identity = tf.Variable(tf.convert_to_tensor(np.eye(mu_shape[-1].value), dtype=tf.float32))
- Sigma = tf.batch_matmul(L,tf.matrix_transpose(L)) + 1e-4*identity
- # Check positive definite
- def _debug_print_func(Sigma,L):
- try:
- C = np.linalg.cholesky(Sigma)
- except np.linalg.LinAlgError:
- print 'LinAlgError'
- return Sigma
- [Sigma] = tf.py_func(_debug_print_func, [Sigma,L], [tf.float32])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement