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

fgrad with pytrees #4

Merged
merged 1 commit into from
Jun 7, 2023
Merged

fgrad with pytrees #4

merged 1 commit into from
Jun 7, 2023

Conversation

ASEM000
Copy link
Owner

@ASEM000 ASEM000 commented Jun 7, 2023

This PR adds the ability to differentiate arbitrary pytrees using fgrad, value_and_fgrad

import finitediffx as fdx

params = {"a":1., "b":2., "c":3.}

@fdx.fgrad
def func(params):
    return params["a"]**2+params["b"]

func(params)
# {'a': Array(1.9995117, dtype=float32),
#  'b': Array(0.9995117, dtype=float32),
#  'c': Array(0., dtype=float32)}

@codecov
Copy link

codecov bot commented Jun 7, 2023

Codecov Report

Patch coverage: 94.36% and project coverage change: -0.43 ⚠️

Comparison is base (2ce5d2a) 98.82% compared to head (35f731d) 98.40%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #4      +/-   ##
==========================================
- Coverage   98.82%   98.40%   -0.43%     
==========================================
  Files           6        6              
  Lines         594      625      +31     
==========================================
+ Hits          587      615      +28     
- Misses          7       10       +3     
Impacted Files Coverage Δ
finitediffx/_src/fgrad.py 93.52% <93.22%> (-1.31%) ⬇️
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 e7354e8 into main Jun 7, 2023
@ASEM000 ASEM000 deleted the pytree-fgrad branch June 7, 2023 05: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