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

Enable pytree step_size, offsets input #5

Merged
merged 4 commits into from
Jun 7, 2023
Merged

Conversation

ASEM000
Copy link
Owner

@ASEM000 ASEM000 commented Jun 7, 2023

import finitediffx as fdx
import jax.numpy as jnp

params = {"a": 1.0, "b": 2.0, "c": 3.0}


def f(params):
    return params["a"] ** 2 + params["b"]


step_size = {"a": 1, "b": 1, "c": 1}
offsets = {
    "a": jnp.array([-1, 1]),
    "b": jnp.array([-1, 1]),
    "c": jnp.array([-1, 1]),
}

fdx.fgrad(f, step_size=step_size, offsets=offsets)(params)
# {'a': Array(2., dtype=float32),
#  'b': Array(1., dtype=float32),
#  'c': Array(0., dtype=float32)}

@codecov
Copy link

codecov bot commented Jun 7, 2023

Codecov Report

Patch coverage: 93.02% and project coverage change: -3.31 ⚠️

Comparison is base (a648314) 98.39% compared to head (33a7dff) 95.08%.

❗ Current head 33a7dff differs from pull request most recent head e145aa8. Consider uploading reports for the commit e145aa8 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #5      +/-   ##
==========================================
- Coverage   98.39%   95.08%   -3.31%     
==========================================
  Files           6        6              
  Lines         624      672      +48     
==========================================
+ Hits          614      639      +25     
- Misses         10       33      +23     
Impacted Files Coverage Δ
finitediffx/_src/fgrad.py 80.12% <88.88%> (-13.36%) ⬇️
finitediffx/_src/utils.py 97.87% <100.00%> (ø)
tests/test_fgrad.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ASEM000 ASEM000 merged commit c6e13c4 into main Jun 7, 2023
@ASEM000 ASEM000 deleted the pytree_step_size_offsets branch June 7, 2023 15:04
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.

1 participant