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

Relax absolute tolerance for failing tests involving chex.assert_trees_all_close. #1069

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion optax/_src/alias_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,9 @@ def test_plain_preconditioning(self):
expected_precond_vec = precond_mat.dot(
vec, precision=jax.lax.Precision.HIGHEST
)
chex.assert_trees_all_close(plain_precond_vec, expected_precond_vec)
chex.assert_trees_all_close(
plain_precond_vec, expected_precond_vec, rtol=1e-5
)

@parameterized.product(idx=[0, 1, 2, 3])
def test_preconditioning_by_lbfgs_on_vectors(self, idx: int):
Expand Down
4 changes: 2 additions & 2 deletions optax/_src/linesearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ def test_linesearch(self, problem_name: str, seed: int):
with self.subTest('Check against scipy'):
stepsize = otu.tree_get(final_state, 'learning_rate')
final_value = otu.tree_get(final_state, 'value')
chex.assert_trees_all_close(scipy_res[0], stepsize, atol=1e-5)
chex.assert_trees_all_close(scipy_res[3], final_value, atol=1e-5)
chex.assert_trees_all_close(scipy_res[0], stepsize, rtol=1e-5)
chex.assert_trees_all_close(scipy_res[3], final_value, rtol=1e-5)

def test_failure_descent_direction(self):
"""Check failure when updates are not a descent direction."""
Expand Down
10 changes: 5 additions & 5 deletions optax/contrib/_dog.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ def dog(
... grad, opt_state, params, value=value)
... params = optax.apply_updates(params, updates)
... print('Objective function: ', f(params))
Objective function: 13.999964
Objective function: 13.999941
Objective function: 13.999905
Objective function: 13.999857
Objective function: 13.999794
Objective function: 13.99...
Objective function: 13.99...
Objective function: 13.99...
Objective function: 13.99...
Objective function: 13.99...

References:
Ivgi et al., `DoG is SGD's Best Friend: A Parameter-Free Dynamic Step
Expand Down
Loading