mirror of
https://github.com/wassname/denoising-diffusion-pytorch.git
synced 2026-09-09 11:21:11 +08:00
clamp the sigma coming out of the log normal distribution
This commit is contained in:
@@ -99,7 +99,8 @@ class ElucidatedDiffusion(nn.Module):
|
||||
# noise distribution
|
||||
|
||||
def noise_distribution(self, batch_size):
|
||||
return (self.P_mean + self.P_std * torch.randn((batch_size,), device = self.device)).exp()
|
||||
sigmas = (self.P_mean + self.P_std * torch.randn((batch_size,), device = self.device)).exp()
|
||||
return sigmas.clamp(min = self.sigma_min, max =self.sigma_max)
|
||||
|
||||
def loss_weight(self, sigma):
|
||||
return (sigma ** 2 + self.sigma_data ** 2) * (sigma * self.sigma_data) ** -2
|
||||
|
||||
Reference in New Issue
Block a user