11"""
2- GaussianDiffusion: Gaussian Diffusion Process Implementation
2+ GaussianDiffusion: Gaussian Diffusion Process Implementation.
33
44Author: Maria Carolina Novitasari
55
1919from typing import Tuple
2020
2121import torch
22- import torch .nn .functional as F
22+ import torch .nn .functional as f
2323
2424
2525class GaussianDiffusion :
2626 """
2727 Implements the forward and reverse processes of a Denoising Diffusion Probabilistic Model (DDPM),
2828 including support for cosine and linear beta schedules.
2929 """
30+
3031
31- def __init__ (self , timesteps : int = 1000 , beta_schedule : str = "cosine" ):
32+ def __init__ (self , timesteps : int = 1000 , beta_schedule : str = "cosine" ) -> None :
3233 """
3334 Initialize diffusion parameters and precompute useful constants.
3435
@@ -45,7 +46,7 @@ def __init__(self, timesteps: int = 1000, beta_schedule: str = "cosine"):
4546
4647 self .alphas = 1.0 - self .betas
4748 self .alphas_cumprod = torch .cumprod (self .alphas , axis = 0 )
48- self .alphas_cumprod_prev = F .pad (self .alphas_cumprod [:- 1 ], (1 , 0 ), value = 1.0 )
49+ self .alphas_cumprod_prev = f .pad (self .alphas_cumprod [:- 1 ], (1 , 0 ), value = 1.0 )
4950 self .sqrt_alphas_cumprod = torch .sqrt (self .alphas_cumprod )
5051 self .sqrt_one_minus_alphas_cumprod = torch .sqrt (1.0 - self .alphas_cumprod )
5152 self .sqrt_recip_alphas = torch .sqrt (1.0 / self .alphas )
@@ -69,7 +70,7 @@ def __init__(self, timesteps: int = 1000, beta_schedule: str = "cosine"):
6970 / (1.0 - self .alphas_cumprod )
7071 )
7172
72- def _cosine_beta_schedule (self , timesteps , s = 0.008 ):
73+ def _cosine_beta_schedule (self , timesteps : int , s : float = 0.008 ) -> torch . Tensor :
7374 """
7475 Compute beta schedule using a cosine function.
7576
0 commit comments