title: Tensorflow: Unexpected behaviour
body: <p>I run the same training script twice, with completely different results. The only difference is the Python operation inserted with this code</p>
  
  <pre><code># 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])
  </code></pre>
  
  <p>So when the last line is commented out the error decreases to ~-40 while (than a not positive definite error occurs). With the Python operation (that actually does not nothing) the error has a very different value.</p>
  
  <p>What could explain this behaviour? I ran this a lot of times, with this same phenomena each time</p>
  
  <p><a href="https://i.stack.imgur.com/k61VT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k61VT.png" alt="enter image description here"></a></p>