-
Notifications
You must be signed in to change notification settings - Fork 3
Adding quartic prior #8
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
base: main
Are you sure you want to change the base?
Conversation
Nice! - will take a look tonight Edit: I will let others take a look first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the PR. I have a problem with the functional form that this prior has, I think it has redundant parameters for a polynomial which can induce inestabilities in the fit.
If people have already worked with a functional form like this and it works most of the time then maybe we could merge it but I would be against it.
It would also be interesting to hear the opinion of @jacopoventurin who I think has worked with similar functional forms before.
mlcg/nn/prior.py
Outdated
@staticmethod | ||
def _quartic_model(x, a, b, c, d, xa, xb, xc): | ||
return a * (x - xa) ** 2 + b * (x - xb) ** 3 + c * (x - xc) ** 4 + d | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A deg 4 polynomial p(x) is uniquely caracterized by 5 numbers: a_0, .. a_4 such that p(x) = sum_{k=0}^4 a_k * x^k. Your degree 4 polynomial uses 7 parameters in order to keep this shape of p(x) = sum_{k=2}^4 b_k *(x_0^{(k)} x)^k. Isn't the fit then ill posed?
At some point I tried to use an expression similar to what you have now and found it problematic because of this redundancy of parameters.
mlcg/nn/prior.py
Outdated
dG_nz: torch.Tensor, | ||
**kwargs, | ||
): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to make a PR also to mlcg-tk because we need to call also the fitting function from there.
So, after some changes and some IRL discussion, we agreed that, even though mathematically ill posed, your functional form was fittable by the use of bound. However, we saw that the same results could be achieved using also a polynomial function properly bounded and we agreed on moving forward with a simpler polynomial. In my most recent push I replaced the Quartic class with the Polynomial and QuarticAngles class, which implement the mentioned polynomial. PLease feel free to test them. I've also opened a PR in mlcg-tk to also support this prior so that you can train a model from scratch and fully test the performance. |
PR Checklist
Describe your changes here:
Added a quartic prior, particularly useful to deal with CA angles resolution