MCPcopy Create free account
hub / github.com/YZY-stack/DF40 / __init__

Method __init__

DeepfakeBench_DF40/training/optimizor/SAM.py:24–31  ·  view source on GitHub ↗
(self, params, base_optimizer, rho=0.05, **kwargs)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected