meissnereric commented on issue #9295: test_operator.test_laop_3 hangs
URL: 
https://github.com/apache/incubator-mxnet/issues/9295#issuecomment-357266519
 
 
   With some help from Zhenwen in debugging the problem, I think we've figured 
out what the bug is that's causing this. Somewhere during syevd the signs of 
the eigenvectors are getting computed or flipped incorrectly.
   
   Haven't found where its introduced or how, but below is some simple example 
code to reproduce the issue. This was running the latest mxnet build as of this 
morning, with MKLML v0.12. 
   
   
   ``` python
   import mxnet as mx
   import numpy as np
   
   np.random.seed(1896893920)
   n=10
   data_in1 = np.random.normal(0., 10., (n, n))
   data_in1 = 0.5 * (data_in1 + data_in1.T)
   
   np_eigval, np_eigvec = np.linalg.eig(data_in1)
   mx_eigvec, mx_eigval = mx.ndarray.linalg.syevd(mx.ndarray.array(data_in1, 
dtype=np.float64))
   
   np.allclose(np_eigval[idx], mx_eigval.asnumpy())
   #True, Eigenvalues are close to each other after sorting the unsorted numpy 
ones
   
   np.allclose(np_eigvec[idx], mx_eigvec.asnumpy())
   #False , but eigenvectors are not the same
   
   np_signs = np.sign(np_eigvec[:,idx].T)[:,0]
   mx_signs = np.sign(mx_eigvec.asnumpy())[:,0]
   
   sign_flips = np_signs * mx_signs
   print(sign_flips)
   #[ 1. -1.  1. -1. -1.  1. -1. -1.  1. -1.], I.E. numpy and mxnet signs not 
the same
   
   np.allclose(np_eigvec[:,idx].T * sign_flips[:,None], mx_eigvec.asnumpy())
   # If we flip the signs to match, now the eigenvectors are all the same.
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to