mirror of
https://github.com/wassname/denoising-diffusion-pytorch.git
synced 2026-09-12 12:22:11 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bbb6ebf16 |
@@ -127,18 +127,12 @@ class ContinuousTimeGaussianDiffusion(nn.Module):
|
|||||||
# sampling related functions
|
# sampling related functions
|
||||||
|
|
||||||
@torch.no_grad()
|
@torch.no_grad()
|
||||||
def p_sample(self, x, time, time_next, eps = 2e-4):
|
def p_sample(self, x, time, time_next):
|
||||||
batch, *_, device = *x.shape, x.device
|
batch, *_, device = *x.shape, x.device
|
||||||
|
|
||||||
model_mean, model_variance = self.p_mean_variance(x = x, time = time, time_next = time_next)
|
model_mean, model_variance = self.p_mean_variance(x = x, time = time, time_next = time_next)
|
||||||
noise = torch.randn_like(x)
|
noise = torch.randn_like(x)
|
||||||
|
return model_mean + sqrt(model_variance) * noise
|
||||||
# no noise when time is below some epsilon
|
|
||||||
# not sure how important this is
|
|
||||||
|
|
||||||
time = repeat(time, ' -> b', b = batch)
|
|
||||||
nonzero_mask = (1 - (time < eps).float()).reshape(batch, *((1,) * (len(x.shape) - 1)))
|
|
||||||
return model_mean + nonzero_mask * sqrt(model_variance) * noise
|
|
||||||
|
|
||||||
@torch.no_grad()
|
@torch.no_grad()
|
||||||
def p_sample_loop(self, shape):
|
def p_sample_loop(self, shape):
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name = 'denoising-diffusion-pytorch',
|
name = 'denoising-diffusion-pytorch',
|
||||||
packages = find_packages(),
|
packages = find_packages(),
|
||||||
version = '0.16.2',
|
version = '0.16.3',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
|
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
|
||||||
author = 'Phil Wang',
|
author = 'Phil Wang',
|
||||||
|
|||||||
Reference in New Issue
Block a user