MCPcopy Index your code
hub / github.com/davda54/sam / second_step

Method second_step

sam.py:30–38  ·  view source on GitHub ↗
(self, zero_grad=False)

Source from the content-addressed store, hash-verified

28
29 @torch.no_grad()
30 def second_step(self, zero_grad=False):
31 for group in self.param_groups:
32 for p in group["params"]:
33 if p.grad is None: continue
34 p.data = self.state[p]["old_p"] # get back to "w" from "w + e(w)"
35
36 self.base_optimizer.step() # do the actual "sharpness-aware" update
37
38 if zero_grad: self.zero_grad()
39
40 @torch.no_grad()
41 def step(self, closure=None):

Callers 2

stepMethod · 0.95
train.pyFile · 0.80

Calls 1

stepMethod · 0.80

Tested by

no test coverage detected