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

Add helper to build hessian vector product #858

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jun 26, 2024

Description

This can be quite useful for optimization, and it's perhaps not trivial for users how to build the expression (it surely wasn't for me)

Actually this was described in the docs, I still think a helper may be easier / more discoverable: https://pytensor.readthedocs.io/en/latest/tutorial/gradients.html#hessian-times-a-vector

tests/test_gradient.py Outdated Show resolved Hide resolved
pytensor/gradient.py Outdated Show resolved Hide resolved
pytensor/gradient.py Outdated Show resolved Hide resolved
pytensor/gradient.py Outdated Show resolved Hide resolved
@ricardoV94 ricardoV94 force-pushed the add_hessian_prod branch 2 times, most recently from 432c14d to f6877ef Compare June 26, 2024 13:43
@ricardoV94 ricardoV94 marked this pull request as ready for review June 26, 2024 13:53
@ricardoV94 ricardoV94 force-pushed the add_hessian_prod branch 3 times, most recently from 673f70f to 93a768d Compare June 26, 2024 16:08
@ricardoV94
Copy link
Member Author

Failing tests are probably due to changes in new scipy that was released 2 days ago

@ricardoV94 ricardoV94 force-pushed the add_hessian_prod branch 2 times, most recently from 43a77a6 to 3d3f3be Compare June 27, 2024 17:48
@ricardoV94 ricardoV94 marked this pull request as draft June 27, 2024 17:48
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.20%. Comparing base (f4e249d) to head (ce484de).
Report is 117 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #858   +/-   ##
=======================================
  Coverage   81.20%   81.20%           
=======================================
  Files         170      170           
  Lines       46992    47001    +9     
  Branches    11510    11512    +2     
=======================================
+ Hits        38160    38169    +9     
  Misses       6621     6621           
  Partials     2211     2211           
Files with missing lines Coverage Δ
pytensor/gradient.py 77.64% <100.00%> (+0.27%) ⬆️

@ricardoV94 ricardoV94 force-pushed the add_hessian_prod branch 2 times, most recently from 856a92b to b5bf4fe Compare June 27, 2024 20:07
@ricardoV94 ricardoV94 marked this pull request as ready for review July 8, 2024 09:36
Copy link
Member

@aseyboldt aseyboldt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is any reason to require wrt and p to be 1d. As long as wrt and p have the same shape(s) everything should be fine.

Maybe we can add a test for that and remove the "1-dimensional" from the docs?
Otherwise this look good.

@ricardoV94 ricardoV94 merged commit 5fd729d into pymc-devs:main Jul 8, 2024
59 checks passed
@ricardoV94
Copy link
Member Author

I don't think there is any reason to require wrt and p to be 1d. As long as wrt and p have the same shape(s) everything should be fine.

Maybe we can add a test for that and remove the "1-dimensional" from the docs? Otherwise this look good.

Sorry @aseyboldt I missed your comment before pressing the green button! Opening an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gradients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants