-
Notifications
You must be signed in to change notification settings - Fork 17
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
Changes from 3 commits
74af37b
f1a9496
853ad4f
15d33a9
b1f2f07
ab7e263
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
import scico.numpy as snp | ||
from scico import functional, linop, loss | ||
from scico.array import complex_dtype | ||
from scico.random import randn | ||
from scico.random import randn, uniform | ||
|
||
|
||
class TestLoss: | ||
|
@@ -208,3 +208,12 @@ def test_prox(self, loss_tuple): | |
|
||
pf = prox_test((1 + 1j) * snp.zeros(self.v.shape), L, L.prox, 0.0) # complex zero v | ||
pf = prox_test((1 + 1j) * snp.zeros(self.v.shape), L, L.prox, 1.0) # complex zero v | ||
|
||
|
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed they were. Fixed. |
||
r = loss._dep_cubic_root(p, q) | ||
err = snp.abs(r**3 + p * r + q) | ||
assert err.max() < 1e-4 |
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.
consider seeding rng here so the test result is not stochastic
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.
Fixed.