dimanche 17 mai 2015

scipy linalg deterministic/non-deterministic code

I'm running this SVD solver from scipy with the below code:

import numpy as np
from scipy.sparse.linalg import svds

features = np.arange(9,dtype=np.float64).reshape((3,3))
for i in range(10):
    _,_,V = svds(features,2)
    print i,np.mean(V)

I expected the printed mean value to be the same each time, however it changes and seems to cycle through a few favourite values. I'm happy to accept that behaviour as a consequence of the low level optimisation/random seeding.

What I don't quite get is why it will output the same values in the same order each time I run that script. To me it seems semi deterministic and semi non-deterministic.

This is problem is affecting some more complicated processing and it would be nice to understand it so I can at least do some hacky workaround.




Aucun commentaire:

Enregistrer un commentaire