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

Conditional variable initialisation in AmiciObjective.check_gradients_match_finite_differences #1494

Open
m-philipps opened this issue Oct 20, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@m-philipps
Copy link
Contributor

Gradient check for an AmiciObjective

pypesto_problem.objective.check_gradients_match_finite_differences(
        x=startpoints[0],
    )

invokes an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/maren/pyPESTO/pypesto/objective/amici/amici.py", line 665, in check_gradients_match_finite_differences
    *args, x=x, x_free=x_free, **kwargs
                       ^^^^^^
UnboundLocalError: cannot access local variable 'x_free' where it is not associated with a value

This is because x_free is only created if the condition in line 651 is True.

Version 0.5.1

@m-philipps m-philipps added the bug Something isn't working label Oct 20, 2024
@m-philipps m-philipps self-assigned this Oct 20, 2024
@m-philipps
Copy link
Contributor Author

Is there a point to inheriting the check_gradients_match_finite_differences in the scope of AmiciObjective. at all? Using the PEtab nominal parameter vector is only used for testing and that default behaviour should at least be documented.

@m-philipps
Copy link
Contributor Author

Linked to #723

@dweindl
Copy link
Member

dweindl commented Oct 21, 2024

Is there a point to inheriting the check_gradients_match_finite_differences in the scope of AmiciObjective. at all? Using the PEtab nominal parameter vector is only used for testing and that default behaviour should at least be documented.

From my point of view, this could be removed completely. There is no clear understanding of what should be given as nominal parameter, but most often this will be the optimized parameters, which is not the best location for the finite difference checks due to vanishing gradients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants