-
Notifications
You must be signed in to change notification settings - Fork 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
Initialization #252
Initialization #252
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## development #252 +/- ##
===============================================
- Coverage 97.30% 97.23% -0.07%
===============================================
Files 18 21 +3
Lines 1669 1884 +215
===============================================
+ Hits 1624 1832 +208
- Misses 45 52 +7 ☔ View full report in Codecov by Sentry. |
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.
Some notes:
- Probably worth copying over your comment in the linked issue that describes what is being done here (and why).
- Also, we should probably get in the habit of adding Examples sections in the docstrings of user-facing functions as we write the function.
- There look like there are a lot of changes to the
test_glm.py
file that are just black being run on it for the first time. Should we include running black on the test files?
) | ||
def test_initialization_error(non_linearity, expectation): | ||
"""Initialize invalid.""" | ||
output_y = np.full((10, 2), np.nan) |
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.
there are other contexts where this fails than having a nan in the output right? we should test them instead, yeah?
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.
hard to hit exception due to fitting not working. we can try using a function that cannot be inverted, that may lead to the search to diverge to inf?
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.
Added an additional test in which the link function cannot be inverted to get the mean rate
raise ValueError( | ||
"Could not set the initial intercept as the inverse of the firing rate for " | ||
"the provided link function. " | ||
"Please, provide initial parameters instead!" |
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.
In general, we can't provide any info as to why this failed, right? I think this message is a bit opaque for users (for example), but maybe we are treating users who use a non-standard link function as advanced.
I do think we could have initialize_intercept_matching_mean_rate
catch this ValueError and raise a more specific error, saying that we were unable to set the initial parameters to match the mean firing rate.
Copying over my comments from #243.: Comment 1Hi Luigi, first of all, thanks for this issue, really appreciate all the details provided. I am looking into it now; The initialization was meant to find a numerical inverse of the link function. For exp, we know it is log, but since we allow to pass any arbitrary non-linearity I wanted a more general approach; I had that issue already, and I thought I'd fixed it using scipy root finding to get the inverse, which was stable enough on my tests. Comment 2@vigji I probably won't be able to merge this in by this week because we are under a deadline, but I created a branch that fixes the issue by:
If you want to test it out, try this branch. If you want to check the numerical inversion on the real data too, pass as a link function lambda x: jax.numpy.exp(x) instead of the exponential directly. |
Co-authored-by: William F. Broderick <[email protected]>
update error string
In this PR I fix the initialization issue in #243;
Additionally, I removed the parallel testing from the default configuration of pytest, but added the parallelization it in the tox.ini call instead.
The reason for this is that debugging tests is much easier without parallelization; Additionally, when debugging, one often needs to run a single test function or a few of them, and the overhead of starting workers makes it slower the single core option.