Skip to content

Commit

Permalink
clamp the sigma coming out of the log normal distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Jun 28, 2022
1 parent 76b79aa commit 6184937
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion denoising_diffusion_pytorch/elucidated_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def c_noise(self, sigma):
# 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
Expand Down

0 comments on commit 6184937

Please sign in to comment.