clamp the sigma coming out of the log normal distribution

This commit is contained in:
Phil Wang
2022-06-28 14:34:39 -07:00
parent 76b79aa847
commit 618493714f
@@ -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