MCPcopy Create free account
hub / github.com/PrathamLearnsToCode/paper2code / forward

Method forward

skills/paper2code/worked/ddpm/src/loss.py:43–60  ·  view source on GitHub ↗

§3.4, Eq. 14 — L_simple = E[||ε − ε_θ(x_t, t)||²] Args: noise_pred: (batch, C, H, W) — predicted noise ε_θ(x_t, t) noise_true: (batch, C, H, W) — true noise ε ~ N(0, I) Returns: scalar — mean squared error loss

(
        self,
        noise_pred: torch.Tensor,
        noise_true: torch.Tensor,
    )

Source from the content-addressed store, hash-verified

41 super().__init__()
42
43 def forward(
44 self,
45 noise_pred: torch.Tensor,
46 noise_true: torch.Tensor,
47 ) -> torch.Tensor:
48 """
49 §3.4, Eq. 14 — L_simple = E[||ε − ε_θ(x_t, t)||²]
50
51 Args:
52 noise_pred: (batch, C, H, W) — predicted noise ε_θ(x_t, t)
53 noise_true: (batch, C, H, W) — true noise ε ~ N(0, I)
54
55 Returns:
56 scalar — mean squared error loss
57 """
58 # §3.4 — Simple MSE between predicted and true noise
59 # "equivalent to (a re-weighted variant of) the ELBO"
60 return nn.functional.mse_loss(noise_pred, noise_true)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected