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

HOWTO: Per example gradient #306

Closed
wants to merge 1 commit into from

Conversation

rolandgvc
Copy link
Contributor

This howto exemplifies how per-example gradients can be retrieved using jax.vmap.

@codecov-commenter
Copy link

Codecov Report

Merging #306 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #306   +/-   ##
=======================================
  Coverage   79.33%   79.33%           
=======================================
  Files          34       34           
  Lines        2255     2255           
=======================================
  Hits         1789     1789           
  Misses        466      466           

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 8901bc0...0134435. Read the comment docs.

@rolandgvc rolandgvc changed the title Per example gradient howto HOWTO: Per example gradient Jun 4, 2020
+ grad = jax.tree_map(mean_fn, grads)
+
optimizer = optimizer.apply_gradient(grad)
metrics = compute_metrics(logits, batch['label'])
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to check compute_metrics. It probably computes the loss a second time. Instead, we should use jax.value_and_grad where vmap_loss_grad is computed.

@avital avital added this to the Design notes and patterns milestone Dec 12, 2020
@avital avital modified the milestones: Design notes, Patterns/HOWTOs Dec 29, 2020
@avital avital added Priority: P2 - no schedule Best effort response and resolution. We have no plan to work on this at the moment. Priority: P1 - soon Response within 5 business days. Resolution within 30 days. (Assignee required) and removed Priority: P2 - no schedule Best effort response and resolution. We have no plan to work on this at the moment. labels Dec 29, 2020
@avital
Copy link
Contributor

avital commented Feb 13, 2021

We've redone our HOWTO system. Here's an example of the new format:

Rendered in ReadTheDocs: https://flax.readthedocs.io/en/latest/howtos/ensembling.html
Document source: https://github.com/google/flax/blob/master/docs/howtos/ensembling.rst (see the :testsetup, :testcode and :codediff directives)

We'd happy take pull requests revamping this HOWTO to the new system.

@avital avital added the Status: pull requests welcome We agree with the direction proposed, feel free to give it a shot and file a pull request label Feb 13, 2021
@avital avital removed their assignment Feb 13, 2021
@marcvanzee marcvanzee added Priority: P2 - no schedule Best effort response and resolution. We have no plan to work on this at the moment. and removed Priority: P1 - soon Response within 5 business days. Resolution within 30 days. (Assignee required) labels Sep 13, 2021
@avital
Copy link
Contributor

avital commented Feb 3, 2022

Looks like this PR is inactive, so I'll close it. We're tracking the HOWTO request here: #858

@avital avital closed this Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Priority: P2 - no schedule Best effort response and resolution. We have no plan to work on this at the moment. Status: pull requests welcome We agree with the direction proposed, feel free to give it a shot and file a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants