opera-adt / DSWX-SAR

Dynamic Surface Water Extent from Synthetic Aperture Radar
Apache License 2.0
11 stars 6 forks source link

Curve fit with analytical Jacobian #87

Closed seongsujeong closed 2 months ago

seongsujeong commented 4 months ago

This PR is an attempt to minimize the CPU / OS - dependent issue that can cause discrepancy on the output result from this software. One of the culprit was the difference in spicy curve_fit results from different platforms, which might be related to the precision handling of floating point numbers because curve_fit computes the gradient (esp. Jacobian matrix) numerically.

One of the strategy to mitigate this issue is to analytically compute the gradient, rather than numerically. curve_fit is capable of taking in the analytical Jacobian function and make use of that for the iteration.

The plot below illustrates how much discrepancy (in # pixels) it has between AMD and Intel CPUs when using the numerical Jacobian (black solid line) and analytical Jacobian (red solid line).

output

hfattahi commented 4 months ago

@seongsujeong Thanks for this PR. Please open an issue and describe the observation that the result of scipy curve fit is changing for the same scipy version on AMD and Intel CPUs.

We know that the scipy curve_fit with numerical gradients on Intel CPUs provides reasonable/expected results. But it is not clear if the results on Intel CPU for both analytical and numerical gradients are identical or not.

Also unless the two approach have been tested extensively, I don't think if we should merge the PR.

seongsujeong commented 2 months ago

closing this PR as the team decided NOT to merge this.