DifferentiableUniverseInitiative / GalFlow

A TensorFlow reimplementation of GalSim
MIT License
10 stars 4 forks source link

Worse result with the new interpolator #18

Open b-remy opened 2 years ago

b-remy commented 2 years ago

I was running inference algorithm using the shear transformation with the new interpolation kernel and I had weird results. So I checked only this shear operation of a sersic profile and found worse result when using the bernsteinquitic of our custom addons than when using the standard ResamplingType.BILINEAR...

Here I start from a round sersic profile and compare the shearing between galsim and galflow:

image

Isn't supposed to be the opposite?

b-remy commented 2 years ago

The difference between the above two plots is pretty low. But in practice I use the gradients of this transform. When I run a gradient descent to get e1 and e2 I get the following errors:

andrevitorelli commented 2 years ago

Two questions on that:

  1. In galsim, do you use the quintic interpolation or do you use the default (lanczos) one?
  2. What are you comparing the gradients to? I mean, if you apply autograd(f) vs numdiff(f), it's not clear to me that autograd(f) - numdiff(f) being a bit larger or smaller mean that the interpolation contained in f is better or worse...

ping @Dr-Zero

b-remy commented 2 years ago
  1. In galsim, do you use the quintic interpolation or do you use the default (lanczos) one?

I use the default one, so lanczos I guess. Do you know how to use quintinc in galsim @andrevitorelli ?

  1. What are you comparing the gradients to? I mean, if you apply autograd(f) vs numdiff(f), it's not clear to me that autograd(f) - numdiff(f) being a bit larger or smaller mean that the interpolation contained in f is better or worse...

Here I don't compare autodiff to numdiff. On the first plot I am just comparing the forward shear operation between galsim and galflow. On the second plot I just run a gradient descent on the shear parameters to fit the observation. Both profile have the same sersic index, radius and flux.

andrevitorelli commented 2 years ago

I use the default one, so lanczos I guess. Do you know how to use quintinc in galsim @andrevitorelli ?

I don't know how to configure it galsim to use it globally. I tested with ngmix, where you can define it more easily (I think there are about 2 or 3 places where ngmix defines the interpolator, and changing that takes care of it all).

I'll think a bit about the second question before replying.