From 782c904d3b5240b79fb66929ca8ab9cf6d2496e5 Mon Sep 17 00:00:00 2001 From: Phil Wang Date: Tue, 19 Apr 2022 20:51:50 -0700 Subject: [PATCH] fix cosine beta schedule, thanks to @Zhengxinyang --- denoising_diffusion_pytorch/denoising_diffusion_pytorch.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py b/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py index c3e0e8c..9204090 100644 --- a/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py +++ b/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py @@ -293,8 +293,8 @@ def cosine_beta_schedule(timesteps, s = 0.008): as proposed in https://openreview.net/forum?id=-NEXDKk8gZ """ steps = timesteps + 1 - x = torch.linspace(0, steps, steps) - alphas_cumprod = torch.cos(((x / steps) + s) / (1 + s) * torch.pi * 0.5) ** 2 + x = torch.linspace(0, timesteps, steps) + alphas_cumprod = torch.cos(((x / timesteps) + s) / (1 + s) * torch.pi * 0.5) ** 2 alphas_cumprod = alphas_cumprod / alphas_cumprod[0] betas = 1 - (alphas_cumprod[1:] / alphas_cumprod[:-1]) return torch.clip(betas, 0, 0.999) diff --git a/setup.py b/setup.py index 3c52306..cc2a2fc 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup( name = 'denoising-diffusion-pytorch', packages = find_packages(), - version = '0.9.1', + version = '0.9.2', license='MIT', description = 'Denoising Diffusion Probabilistic Models - Pytorch', author = 'Phil Wang',