MCPcopy Create free account
hub / github.com/10Ring/LAA-Net / __init__

Method __init__

lib/optimizers/sam.py:23–30  ·  view source on GitHub ↗
(self, params, base_optimizer, rho=0.05, **kwargs)

Source from the content-addressed store, hash-verified

21
22class SAM(torch.optim.Optimizer):
23 def __init__(self, params, base_optimizer, rho=0.05, **kwargs):
24 assert rho >= 0.0, f"Invalid rho, should be non-negative: {rho}"
25
26 defaults = dict(rho=rho, **kwargs)
27 super(SAM, self).__init__(params, defaults)
28
29 self.base_optimizer = base_optimizer(self.param_groups, **kwargs)
30 self.param_groups = self.base_optimizer.param_groups
31
32 @torch.no_grad()
33 def first_step(self, zero_grad=False):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected