-
Notifications
You must be signed in to change notification settings - Fork 330
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
[BUG] Are weighted norms in SR3 classes computed incorrectly? #394
Comments
Jacob-Stevens-Haas
changed the title
[BUG] Weighted norms in all SR3 classes may be wrong
[BUG] Are weighted norms in SR3 classes computed incorrectly?
Aug 16, 2023
@himkwtn this is a decent issue that is a little bit mathy, but beyond the |
I found that StableLinearSR3 might be calculating the l2 regularization term incorrectly.
If I understand correctly, it should be |
as I understand it, this line is in a conditional for weighted l2 norm. So it should be something like cp.norm2(np.sqrt(self.thresholds) * np.ravel(xi)) |
Jacob-Stevens-Haas
pushed a commit
that referenced
this issue
Sep 10, 2024
Now, prox and regularization have a more plain API: weights are either scalars or must match the shape of the optimization variable. This removes weird use cases that only worked because of broadcasting, which constrained our ability to simplify It also fixes the calculation of regularizers in SR3 _calculate_penalty, with the aim that this will also be replaced with get_prox and get_regularization when they are able to handle CVXPY (or JAX) expressions (arrays)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SR3
and its subclasses use weighted norms in two types of expressions; in both cases, it appears that those classes get it wrong.calculated using cvxpy
This is odd because the
xi
is a 1d vector, as isnp.ravel(...)
, which means both are probably computing the norm of a scalar, not a vector.calculated using
pysindy.utils.base.get_regularization()
This function doesn't have any unit tests, so it's tricky to see how it expects inputs, but this line indicates that the thresholds may not be properly applied (
self.reg
is the lambda function returned byget_regularization
,coeff_full
is (n_features, n_targets) andself.thresholds
is (n_targets, n_features)). It seems like elementwise multiplication, rather than matrix multiplication, is what's desired here.Reproducing code example:
I haven't built a small regression problem to prove these things are wrong, because I haven't worked with
SR3
other than speeding up the tests in #393. But its easy to see thatget_regularization()
returns the norm of the inner product, even though weights are (I think?) supposed to be elementwiseError message:
Both show that the norm is 2.
Thoughts
Broadly speaking, here's what are probably the next steps. Caveat, very little of my work deals with
SR3
, and none withSR3
weighted thresholding, so I may get through step 1 at the most.pysindy.utils.base
thatSR3
uses.@briandesilva , @akaptano , @kpchamp, I know this is old code, but if you have any time in the coming months to review, I'd appreciate it.
The text was updated successfully, but these errors were encountered: