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

[REF] Replicate base class, but inherit from PyTorch linear operator #142

Merged
merged 9 commits into from
Nov 4, 2024

Conversation

f-dangel
Copy link
Owner

This PR introduces a class CurvatureLinearOperator, which is almost identical to the current base class _LinearOperator, but inherits from PyTorchLinearOperator.

The next steps will be to (i) migrate each linear operator to inherit from CurvatureLinearOperator, rather than _LinearOperator, (ii) delete _LinearOperator.

@coveralls
Copy link

coveralls commented Oct 25, 2024

Pull Request Test Coverage Report for Build 11667319095

Details

  • 65 of 116 (56.03%) changed or added relevant lines in 3 files are covered.
  • 56 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-5.2%) to 86.417%

Changes Missing Coverage Covered Lines Changed/Added Lines %
curvlinops/utils.py 5 8 62.5%
curvlinops/_torch_base.py 57 105 54.29%
Files with Coverage Reduction New Missed Lines %
curvlinops/examples/utils.py 10 31.25%
curvlinops/fisher.py 46 26.47%
Totals Coverage Status
Change from base Build 11523760748: -5.2%
Covered Lines: 1476
Relevant Lines: 1708

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11523822133

Details

  • 16 of 110 (14.55%) changed or added relevant lines in 2 files are covered.
  • 72 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-8.2%) to 83.421%

Changes Missing Coverage Covered Lines Changed/Added Lines %
curvlinops/utils.py 2 8 25.0%
curvlinops/_torch_base.py 14 102 13.73%
Files with Coverage Reduction New Missed Lines %
curvlinops/examples/utils.py 10 31.25%
curvlinops/_torch_base.py 16 40.56%
curvlinops/fisher.py 46 26.47%
Totals Coverage Status
Change from base Build 11523760748: -8.2%
Covered Lines: 1424
Relevant Lines: 1707

💛 - Coveralls

curvlinops/_torch_base.py Outdated Show resolved Hide resolved
curvlinops/_torch_base.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@runame runame left a comment

Choose a reason for hiding this comment

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

LGTM!

Would be good to add unit tests, at least of all public methods.

curvlinops/_torch_base.py Show resolved Hide resolved
@f-dangel
Copy link
Owner Author

f-dangel commented Nov 4, 2024

Added the following test: In this PR, CurvatureLinearOperator has two public functions: to_device, and gradient_and_loss. The to_device function will be deprecated soon, therefore I am not adding a test here (it is also called by the other linear operators in their deterministic checks, therefore tested indirectly). I added an explicit test which makes sure that the loss and gradient are correctly accumulated over a data set. This functionality was tested indirectly before by making sure the curvature matrix-vector products are correctly accumulated over a data set. Now there is an explicit test which only relies on the base class.

@f-dangel f-dangel merged commit 2ae34be into main Nov 4, 2024
13 checks passed
@f-dangel f-dangel deleted the curvature-linop branch November 4, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants