Sorry for the cryptic title, but I don't know a better way to describe it. While I was playing around with the PR to add a structural similarity function <https://github.com/scikits-image/scikits-image/pull/119>, I found that summing over an array doesn't give consistent results on my system (example script below). The example script is pulled from the structural similarity function. The test is run in a loop because the error appears randomly---running the test with the *exact* same arrays will fail on one attempt but not another. Random observations: - the failure is more likely to occur with large arrays - the failure *does not occur* without the subtraction of `ux` (see script) - this seems like some sort of memory alignment error (maybe something to do with `as_strides`, which is used by view_as_windows) Can anyone reproduce this? (Script below will print an array when it fails; otherwise it exits without printing anything) I know this is probably more of numpy issue (if it's reproducible), but I want to try to reproduce it before rewriting the example without calling `view_as_windows`. Thanks, -Tony #~~~ # requires somewhat-recent master because of call to view_as_windows. import sys import numpy as np from skimage.util.shape import view_as_windows def test_func(X, Y, win_size=7): XW = view_as_windows(X, (win_size, win_size)) ux = np.mean(np.mean(XW, axis=2), axis=2) XWM = XW - ux[..., None, None] # Repeat *exact same calculation* and check that they give the same value. vx1 = np.sum(np.sum(XWM, axis=2), axis=2) vx2 = np.sum(np.sum(XWM, axis=2), axis=2) if not np.allclose(vx1, vx2): diff = vx1 - vx2 print diff[np.nonzero(diff)] sys.exit() X = np.random.uniform(size=(30, 30)) Y = np.random.uniform(size=(30, 30)) for i in xrange(100): test_func(X, Y)
participants (1)
-
Tony Yu