f-dangel / curvlinops

scipy linear operators for the Hessian, Fisher/GGN, and more in PyTorch
https://curvlinops.readthedocs.io/en/latest/
MIT License
17 stars 5 forks source link

Add `trace`, `det`, `logdet`, and `frobenius_norm` property to `KFACLinearOperator` #95

Closed runame closed 6 months ago

runame commented 6 months ago

Resolves #96.

Please merge #91 before reviewing this PR.

coveralls commented 6 months ago

Pull Request Test Coverage Report for Build 8383381257

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
curvlinops/kfac.py 68 74 91.89%
<!-- Total: 68 74 91.89% -->
Totals Coverage Status
Change from base Build 8364730614: 0.1%
Covered Lines: 1084
Relevant Lines: 1211

💛 - Coveralls
runame commented 6 months ago

No, the main reason for using properties here is the caching and that it fits semantically (they are attributes/properties of the matrix). I think the resetting is a small price to pay for being able to cache the result, especially since we just have to add one new line in the resetting method for every additional property we implement, so seems easy to extend.