Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to use full polynomial in ML linesearch #487

Merged
merged 4 commits into from
Mar 8, 2024

Conversation

jfowkes
Copy link
Collaborator

@jfowkes jfowkes commented Apr 6, 2023

Resurrecting #392 as GitHub broke the original PR.

It has been observed that ML shows spikes in the likelihood error, this appears to be due to the use of an approximate quadratic polynomial in the linesearch instead of the full octic polynomial as described in the ML paper. This PR adds an option all_line_coeffs to enable the full octic polynomial at at cost of about 60% more computation in the coefficient calculation stage at each iteration.

Caveats:

  • np.roots only supports np.double not np.longdouble (may need to write our own roots function). This is not an issue for the moonflower test dataset as the full precision of long double is not required there. However, it probably will be on some real datasets.

@daurer daurer marked this pull request as ready for review February 1, 2024 14:02
@daurer daurer added the 0.8.1 path release label Feb 29, 2024
Copy link
Member

@pierrethibault pierrethibault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be merged. Not sure why the old way (internal quad_approx switch) is not used instead of the suggested duplicate code. See https://github.com/ptycho/legacy-ptycho/blob/2fade96aaf773a11c3aae318868ac711a0a5ff6c/lib/core_object_modes.py#L3494

self.B = B

return B

def poly_line_all_coeffs(self, ob_h, pr_h):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to have a single method with an internal switch based on 'quadratic' or 'all'? It feels like there is a lot of repetition between the two...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there is a lot of code duplication, but I believe @daurer preferred it this way as there's no risk of breakage...

@jfowkes
Copy link
Collaborator Author

jfowkes commented Mar 5, 2024

@pierrethibault simply because I don't have access to ptycho-legacy so I didn't know there was an old way.

@pierrethibault
Copy link
Member

As discussed with @daurer and @bjoernenders, we can merge this, and keep in mind possible improvements to reduce code duplication, and possibly to allow other truncation levels since the line-search for the gaussian model is an order 8 polynomial and the Taylor expansion of the Poisson and Euclidean models is infinite.

@daurer daurer merged commit 02e17a4 into ptycho:dev Mar 8, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.8.1 path release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants