CosmoStat / autometacal

Metacalibration and shape measurement by automatic differentiation
MIT License
4 stars 1 forks source link

Issue with batched operations generating metacal images #22

Closed andrevitorelli closed 3 years ago

andrevitorelli commented 3 years ago

I have been getting different results when I generate metacal images one per one, in for loops, or batched altogether. It is not a non-deterministic operation (as checked by working with 1 image twice and getting zero difference), but when I do batched, the results come out close, but different. Just by looking at the values you'd think they are numerical errors, but that creates different results in our analysis comparing autodiff and finite diferences. I uploaded a notebook here: https://github.com/CosmoStat/autometacal/blob/mcal_auto_finite_test/notebooks/batched_generate_mcal_bug.ipynb

In essence, given 2 entries, if you do either


gal_image = gal_images[0:2]
psf_image = psf_images[0:2]
img0s1 = autometacal.generate_mcal_image(gal_image,psf_image,reconv_psf_image,[[0,0]])

or

gal_image = gal_images[0:1]
psf_image = psf_images[0:1]
img0s2 = autometacal.generate_mcal_image(gal_image,psf_image,reconv_psf_image,[[0,0]])

img0s1[0]and img0s2[0] come out different.

Any thoughts, @EiffL?

andrevitorelli commented 3 years ago

The bug is in how ifftshift works regarding axes, I'm trying to find a solution now. It was just adding axes=[1,2] at the end of each shift. Proceeding with bugfix.