Skip to content

Commit 532178a

Browse files
committed
assume when sampling all batch samples are at the same time, and do not noise for the last time step
1 parent 3bbb6eb commit 532178a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

denoising_diffusion_pytorch/continuous_time_gaussian_diffusion.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ def p_sample(self, x, time, time_next):
131131
batch, *_, device = *x.shape, x.device
132132

133133
model_mean, model_variance = self.p_mean_variance(x = x, time = time, time_next = time_next)
134+
135+
if time_next == 0:
136+
return model_mean
137+
134138
noise = torch.randn_like(x)
135139
return model_mean + sqrt(model_variance) * noise
136140

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name = 'denoising-diffusion-pytorch',
55
packages = find_packages(),
6-
version = '0.16.3',
6+
version = '0.16.4',
77
license='MIT',
88
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
99
author = 'Phil Wang',

0 commit comments

Comments
 (0)