MCPcopy Index your code
hub / github.com/PrathamLearnsToCode/paper2code / update

Method update

skills/paper2code/worked/ddpm/src/utils.py:225–231  ·  view source on GitHub ↗

Update EMA weights after each training step.

(self, model: nn.Module)

Source from the content-addressed store, hash-verified

223
224 @torch.no_grad()
225 def update(self, model: nn.Module):
226 """Update EMA weights after each training step."""
227 for name, param in model.named_parameters():
228 if param.requires_grad and name in self.shadow:
229 self.shadow[name].mul_(self.decay).add_(
230 param.data, alpha=1.0 - self.decay
231 )
232
233 def apply(self, model: nn.Module):
234 """Load EMA weights into model (for evaluation/sampling)."""

Callers 1

trainFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected