google-research / google-research/sam

Implementation of the gradient approximation for the SAM objective (eq3)

Open
#14 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
646
Forks
81
PR merge metrics
No merged PRs in 30d

Description

I have read your paper and code carefully.
You use the p as 2, thus SAM firstly maximizes the objective loss function by adding rho * normalized gradients to models' parameters (https://github.com/google-research/sam/blob/dae9904c4cf3a57a304f7b04cecffe371679c702/sam_jax/training_utils/flax_training.py#L537)
And SAM calculates gradients in this noised model again (https://github.com/google-research/sam/blob/dae9904c4cf3a57a304f7b04cecffe371679c702/sam_jax/training_utils/flax_training.py#L549).
In your paper, the gradient is calculated with respect to the original model's parameters, unlike the code which calculates gradient with respect to the noised model's parameters.

Are these two the same?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.