Diffusers 文档
FlowMatchHeunDiscreteScheduler
并获取增强的文档体验
开始使用
FlowMatchHeunDiscreteScheduler
FlowMatchHeunDiscreteScheduler
基于 EDM 中介绍的 flow-matching 采样。
FlowMatchHeunDiscreteScheduler
class diffusers.FlowMatchHeunDiscreteScheduler
< source >( num_train_timesteps: int = 1000 shift: float = 1.0 )
参数
- num_train_timesteps (
int
, 默认为 1000) — 用于训练模型的扩散步骤数。 - timestep_spacing (
str
, 默认为"linspace"
) — 时间步长应缩放的方式。有关更多信息,请参阅 Common Diffusion Noise Schedules and Sample Steps are Flawed 中的表 2。 - shift (
float
, 默认为 1.0) — 时间步长计划的 shift 值。
Heun 调度器。
此模型继承自 SchedulerMixin 和 ConfigMixin。查看超类文档,了解库为所有调度器实现的通用方法,例如加载和保存。
scale_noise
< source >( sample: FloatTensor timestep: typing.Union[float, torch.FloatTensor] noise: typing.Optional[torch.FloatTensor] = None ) → torch.FloatTensor
flow-matching 中的前向过程
设置调度器的起始索引。此函数应在推理之前从pipeline运行。
set_timesteps
< 源代码 >( num_inference_steps: int device: typing.Union[str, torch.device] = None )
设置用于扩散链的离散时间步(在推理之前运行)。
step
< 源代码 >( model_output: FloatTensor timestep: typing.Union[float, torch.FloatTensor] sample: FloatTensor s_churn: float = 0.0 s_tmin: float = 0.0 s_tmax: float = inf s_noise: float = 1.0 generator: typing.Optional[torch._C.Generator] = None return_dict: bool = True ) → ~schedulers.scheduling_Heun_discrete.HeunDiscreteSchedulerOutput
或 tuple
参数
- model_output (
torch.FloatTensor
) — 来自学习扩散模型的直接输出。 - timestep (
float
) — 扩散链中当前的离散时间步。 - sample (
torch.FloatTensor
) — 扩散过程创建的样本的当前实例。 - s_churn (
float
) — - s_tmin (
float
) — - s_tmax (
float
) — - s_noise (
float
, 默认为 1.0) — 添加到样本的噪声的缩放因子。 - generator (
torch.Generator
, 可选) — 随机数生成器。 - return_dict (
bool
) — 是否返回~schedulers.scheduling_Heun_discrete.HeunDiscreteSchedulerOutput
或 tuple。
返回值
~schedulers.scheduling_Heun_discrete.HeunDiscreteSchedulerOutput
或 tuple
如果 return_dict 为 True
,则返回 ~schedulers.scheduling_Heun_discrete.HeunDiscreteSchedulerOutput
,否则返回一个 tuple,其中第一个元素是样本张量。
通过反转 SDE,从上一个时间步预测样本。此函数从学习的模型输出(通常是预测的噪声)传播扩散过程。