Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. # Add a small amount times the identity matrix to prevent errors
  2. identity = tf.Variable(tf.convert_to_tensor(np.eye(mu_shape[-1].value), dtype=tf.float32))
  3. Sigma = tf.batch_matmul(L,tf.matrix_transpose(L)) + 1e-4*identity
  4.  
  5. # Check positive definite
  6. def _debug_print_func(Sigma,L):
  7. try:
  8. C = np.linalg.cholesky(Sigma)
  9. except np.linalg.LinAlgError:
  10. print 'LinAlgError'
  11.  
  12. return Sigma
  13.  
  14. [Sigma] = tf.py_func(_debug_print_func, [Sigma,L], [tf.float32])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement