question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consolidate different gradient checks

See original GitHub issue

Feature description Currently we have several different (rather redundant) gradient checking routines, which only have slightly different functionalities, which in my opinion do not all justify being there in parallel. (In the end: We want to have a minimal interface to the outside world to be user-friendly):

In objective/base https://github.com/ICB-DCM/pyPESTO/blob/0aaa34179497c429434b4b6d2aeb35309b113961/pypesto/objective/base.py#L370

https://github.com/ICB-DCM/pyPESTO/blob/0aaa34179497c429434b4b6d2aeb35309b113961/pypesto/objective/base.py#L422

https://github.com/ICB-DCM/pyPESTO/blob/0aaa34179497c429434b4b6d2aeb35309b113961/pypesto/objective/base.py#L589

In the PEtab importer https://github.com/ICB-DCM/pyPESTO/blob/fb2be819b41411dc1686d8429ce5efa6c535b70b/pypesto/petab/importer.py#L83

Motivation/Application I think, that having one FD check in objective/base and maybe another one for checking multiple eps values is great. The one in the PEtab importer is clearly redundant, since you would rather create a problem object, and then call a gradient check on that (which is also, what the function does…). The third function in the objective base also seems close to the other ones and not “general purpose”.

Therefore I would like to

a) propose to get rid of the gradient check in the PEtab importer and would like to

b) open the discussion, if the third gradient check in objective/base adds enough “general purpose” value, that it justifies to have and maintain an other gradient checking method there.

Opinions? @yannikschaelte @dweindl @stephanmg

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
stephanmgcommented, Sep 1, 2021

As far as this concerns the function I’ve added, I can consolidate in the following way:

  1. check_gradients function in PEtab importer can be removed from the code base (The function can be implemented outside of pyPESTO if really nobody thinks it might be useful to have)

  2. check_gradients_match_finite_differences can be made pseudo-private to not clutter the public API. It willl be used only internally in a visualization method I plan to PR into pyPESTO anyway.

Does this sound reasonable? Feel free to assign me if you think that’s appropriate.

1reaction
yannikschaeltecommented, Sep 1, 2021

If I see correctly, (1)+(2) should be the base implementation. (4) autofills petab nominal parameters, which seems reasonable (not sure if there is room for simplification there though). (3) conceptually takes the output of (2) and actually compares the obtained atols+rtols, which (1)+(2) fail to do. Thus I guess (3) also makes sense to keep, as otherwise one would need to have binary output for (1)+(2) whether the df or bool is of interest. It seems however that (3) could be simplified to e.g. not redefine mode + multi_eps, but just call (2) and evalute the outputs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does it mean to 'gradient check a few dimensions for ...
Check only few dimensions. In practice the gradients can have sizes of million parameters. In these cases it is only practical to check...
Read more >
Debugging neural networks with gradient checking
In this section, we will talk about a simple procedure called gradient checking, which is essentially a comparison between our analytical gradients in...
Read more >
numerical gradient checks - alex hayes
Now we can check the relative error between our analytical implementation of the gradient and the numerical approximation.
Read more >
cs231n/FullyConnectedNets.ipynb at master - GitHub
As a sanity check, run the following to check the initial loss and to gradient check the network both with and without regularization....
Read more >
Multiple Gradients on a Single Object in Affinity Designer
This is the second Affinity Designer tutorial I've created on the subject of Multiple Gradients. In this video I show you the easiest...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found