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

Improve SquaredL2SquaredAbsLoss #278

Merged
merged 6 commits into from
Apr 20, 2022
Merged

Improve SquaredL2SquaredAbsLoss #278

merged 6 commits into from
Apr 20, 2022

Conversation

bwohlberg
Copy link
Collaborator

Improve algorithm, docs, and testing of the cubic equation root calculation used by SquaredL2SquaredAbsLoss.

@bwohlberg bwohlberg added the enhancement New feature or request label Apr 15, 2022
@codecov
Copy link

codecov bot commented Apr 15, 2022

Codecov Report

Merging #278 (ab7e263) into main (e32a106) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #278   +/-   ##
=======================================
  Coverage   93.85%   93.86%           
=======================================
  Files          51       51           
  Lines        3696     3701    +5     
=======================================
+ Hits         3469     3474    +5     
  Misses        227      227           
Flag Coverage Δ
unittests 93.86% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
scico/loss.py 94.97% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e32a106...ab7e263. Read the comment docs.


def test_cubic_root():
N = 10000
p, _ = uniform(shape=(N,), dtype=snp.float32, minval=-10.0, maxval=10.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

consider seeding rng here so the test result is not stochastic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

def test_cubic_root():
N = 10000
p, _ = uniform(shape=(N,), dtype=snp.float32, minval=-10.0, maxval=10.0)
q, _ = uniform(shape=(N,), dtype=snp.float32, minval=-10.0, maxval=10.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

jax gotcha: I think p and q will be equal if you make them this way. Need to get the key from the first call and pass it to the second.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed they were. Fixed.

@bwohlberg bwohlberg merged commit a1838ee into main Apr 20, 2022
@bwohlberg bwohlberg deleted the brendt/absloss branch April 20, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants