"docs/vscode:/vscode.git/clone" did not exist on "8079d98617694b6fc896dedf4c83e7b25dc716cb"
Unverified Commit f6fb3282 authored by Patrick von Platen's avatar Patrick von Platen Committed by GitHub
Browse files

[Outputs] Improve syntax (#423)



* [Outputs] Improve syntax

* improve more

* fix docstring return

* correct all

* uP
Co-authored-by: default avatarMishig Davaadorj <dmishig@gmail.com>
parent 1a79969d
...@@ -58,6 +58,11 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin): ...@@ -58,6 +58,11 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
Denoising diffusion probabilistic models (DDPMs) explores the connections between denoising score matching and Denoising diffusion probabilistic models (DDPMs) explores the connections between denoising score matching and
Langevin dynamics sampling. Langevin dynamics sampling.
[`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
[`~ConfigMixin`] also provides general loading and saving functionality via the [`~ConfigMixin.save_config`] and
[`~ConfigMixin.from_config`] functios.
For more details, see the original paper: https://arxiv.org/abs/2006.11239 For more details, see the original paper: https://arxiv.org/abs/2006.11239
Args: Args:
...@@ -189,7 +194,9 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin): ...@@ -189,7 +194,9 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
Returns: Returns:
`SchedulerOutput`: updated sample in the diffusion chain. [`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`:
[`~schedulers.scheduling_utils.SchedulerOutput`] if `return_dict` is True, otherwise a `tuple`. When
returning a tuple, the first element is the sample tensor.
""" """
t = timestep t = timestep
......
...@@ -50,6 +50,11 @@ class KarrasVeScheduler(SchedulerMixin, ConfigMixin): ...@@ -50,6 +50,11 @@ class KarrasVeScheduler(SchedulerMixin, ConfigMixin):
https://arxiv.org/abs/2206.00364 [2] Song, Yang, et al. "Score-based generative modeling through stochastic https://arxiv.org/abs/2206.00364 [2] Song, Yang, et al. "Score-based generative modeling through stochastic
differential equations." https://arxiv.org/abs/2011.13456 differential equations." https://arxiv.org/abs/2011.13456
[`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
[`~ConfigMixin`] also provides general loading and saving functionality via the [`~ConfigMixin.save_config`] and
[`~ConfigMixin.from_config`] functios.
For more details on the parameters, see the original paper's Appendix E.: "Elucidating the Design Space of For more details on the parameters, see the original paper's Appendix E.: "Elucidating the Design Space of
Diffusion-Based Generative Models." https://arxiv.org/abs/2206.00364. The grid search values used to find the Diffusion-Based Generative Models." https://arxiv.org/abs/2206.00364. The grid search values used to find the
optimal {s_noise, s_churn, s_min, s_max} for a specific model are described in Table 5 of the paper. optimal {s_noise, s_churn, s_min, s_max} for a specific model are described in Table 5 of the paper.
...@@ -147,8 +152,11 @@ class KarrasVeScheduler(SchedulerMixin, ConfigMixin): ...@@ -147,8 +152,11 @@ class KarrasVeScheduler(SchedulerMixin, ConfigMixin):
sample_hat (`torch.FloatTensor` or `np.ndarray`): TODO sample_hat (`torch.FloatTensor` or `np.ndarray`): TODO
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
Returns:
KarrasVeOutput: updated sample in the diffusion chain and derivative (TODO double check). KarrasVeOutput: updated sample in the diffusion chain and derivative (TODO double check).
Returns:
[`~schedulers.scheduling_karras_ve.KarrasVeOutput`] or `tuple`:
[`~schedulers.scheduling_karras_ve.KarrasVeOutput`] if `return_dict` is True, otherwise a `tuple`. When
returning a tuple, the first element is the sample tensor.
""" """
......
...@@ -29,6 +29,11 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin): ...@@ -29,6 +29,11 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
Katherine Crowson: Katherine Crowson:
https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181 https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181
[`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
[`~ConfigMixin`] also provides general loading and saving functionality via the [`~ConfigMixin.save_config`] and
[`~ConfigMixin.from_config`] functios.
Args: Args:
num_train_timesteps (`int`): number of diffusion steps used to train the model. num_train_timesteps (`int`): number of diffusion steps used to train the model.
beta_start (`float`): the starting `beta` value of inference. beta_start (`float`): the starting `beta` value of inference.
...@@ -143,7 +148,9 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin): ...@@ -143,7 +148,9 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
Returns: Returns:
prev_sample (`SchedulerOutput` or `Tuple`): updated sample in the diffusion chain. [`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`:
[`~schedulers.scheduling_utils.SchedulerOutput`] if `return_dict` is True, otherwise a `tuple`. When
returning a tuple, the first element is the sample tensor.
""" """
sigma = self.sigmas[timestep] sigma = self.sigmas[timestep]
......
...@@ -58,6 +58,11 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin): ...@@ -58,6 +58,11 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin):
Pseudo numerical methods for diffusion models (PNDM) proposes using more advanced ODE integration techniques, Pseudo numerical methods for diffusion models (PNDM) proposes using more advanced ODE integration techniques,
namely Runge-Kutta method and a linear multi-step method. namely Runge-Kutta method and a linear multi-step method.
[`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
[`~ConfigMixin`] also provides general loading and saving functionality via the [`~ConfigMixin.save_config`] and
[`~ConfigMixin.from_config`] functios.
For more details, see the original paper: https://arxiv.org/abs/2202.09778 For more details, see the original paper: https://arxiv.org/abs/2202.09778
Args: Args:
...@@ -186,7 +191,9 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin): ...@@ -186,7 +191,9 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin):
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
Returns: Returns:
`SchedulerOutput`: updated sample in the diffusion chain. [`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`:
[`~schedulers.scheduling_utils.SchedulerOutput`] if `return_dict` is True, otherwise a `tuple`. When
returning a tuple, the first element is the sample tensor.
""" """
if self.counter < len(self.prk_timesteps) and not self.config.skip_prk_steps: if self.counter < len(self.prk_timesteps) and not self.config.skip_prk_steps:
...@@ -213,7 +220,8 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin): ...@@ -213,7 +220,8 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin):
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
Returns: Returns:
prev_sample (`SchedulerOutput` or `Tuple`): updated sample in the diffusion chain. [`~scheduling_utils.SchedulerOutput`] or `tuple`: [`~scheduling_utils.SchedulerOutput`] if `return_dict` is
True, otherwise a `tuple`. When returning a tuple, the first element is the sample tensor.
""" """
if self.num_inference_steps is None: if self.num_inference_steps is None:
...@@ -267,7 +275,8 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin): ...@@ -267,7 +275,8 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin):
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
Returns: Returns:
prev_sample (`SchedulerOutput` or `Tuple`): updated sample in the diffusion chain. [`~scheduling_utils.SchedulerOutput`] or `tuple`: [`~scheduling_utils.SchedulerOutput`] if `return_dict` is
True, otherwise a `tuple`. When returning a tuple, the first element is the sample tensor.
""" """
if self.num_inference_steps is None: if self.num_inference_steps is None:
......
...@@ -49,6 +49,11 @@ class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin): ...@@ -49,6 +49,11 @@ class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin):
For more information, see the original paper: https://arxiv.org/abs/2011.13456 For more information, see the original paper: https://arxiv.org/abs/2011.13456
[`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
[`~ConfigMixin`] also provides general loading and saving functionality via the [`~ConfigMixin.save_config`] and
[`~ConfigMixin.from_config`] functios.
Args: Args:
snr (`float`): snr (`float`):
coefficient weighting the step from the model_output sample (from the network) to the random noise. coefficient weighting the step from the model_output sample (from the network) to the random noise.
...@@ -182,7 +187,8 @@ class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin): ...@@ -182,7 +187,8 @@ class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin):
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
Returns: Returns:
prev_sample (`SchedulerOutput` or `Tuple`): updated sample in the diffusion chain. [`~schedulers.scheduling_sde_ve.SdeVeOutput`] or `tuple`: [`~schedulers.scheduling_sde_ve.SdeVeOutput`] if
`return_dict` is True, otherwise a `tuple`. When returning a tuple, the first element is the sample tensor.
""" """
if "seed" in kwargs and kwargs["seed"] is not None: if "seed" in kwargs and kwargs["seed"] is not None:
...@@ -241,7 +247,8 @@ class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin): ...@@ -241,7 +247,8 @@ class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin):
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
Returns: Returns:
prev_sample (`SchedulerOutput` or `Tuple`): updated sample in the diffusion chain. [`~schedulers.scheduling_sde_ve.SdeVeOutput`] or `tuple`: [`~schedulers.scheduling_sde_ve.SdeVeOutput`] if
`return_dict` is True, otherwise a `tuple`. When returning a tuple, the first element is the sample tensor.
""" """
if "seed" in kwargs and kwargs["seed"] is not None: if "seed" in kwargs and kwargs["seed"] is not None:
......
...@@ -27,6 +27,11 @@ class ScoreSdeVpScheduler(SchedulerMixin, ConfigMixin): ...@@ -27,6 +27,11 @@ class ScoreSdeVpScheduler(SchedulerMixin, ConfigMixin):
""" """
The variance preserving stochastic differential equation (SDE) scheduler. The variance preserving stochastic differential equation (SDE) scheduler.
[`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
[`~ConfigMixin`] also provides general loading and saving functionality via the [`~ConfigMixin.save_config`] and
[`~ConfigMixin.from_config`] functios.
For more information, see the original paper: https://arxiv.org/abs/2011.13456 For more information, see the original paper: https://arxiv.org/abs/2011.13456
UNDER CONSTRUCTION UNDER CONSTRUCTION
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment