Diffusers documentation
FlowMatchHeunDiscreteScheduler
FlowMatchHeunDiscreteScheduler
FlowMatchHeunDiscreteScheduler 基于 EDM 中引入的 flow-matching 采样方法。
FlowMatchHeunDiscreteScheduler
类 diffusers.FlowMatchHeunDiscreteScheduler
< source >( num_train_timesteps: int = 1000shift: float = 1.0 )
Heun 调度器。
该模型继承自 SchedulerMixin 和 ConfigMixin。有关该库为所有调度器实现的通用方法(例如加载和保存),请参阅父类文档。
index_for_timestep
< source >( timestep: typing.Union[float, torch.FloatTensor]schedule_timesteps: typing.Optional[torch.FloatTensor] = None ) → int
查找给定时间步在时间步调度中的索引。
scale_noise
< source >( sample: FloatTensortimestep: typing.Union[float, torch.FloatTensor]noise: FloatTensor ) → torch.FloatTensor
流匹配中的前向过程
设置调度器的起始索引。此函数应在推理之前从流水线中运行。
set_timesteps
< source >( num_inference_steps: intdevice: typing.Union[str, torch.device] = None )
设置扩散链所使用的离散时间步(需在推理之前运行)。
步骤
< source >( model_output: FloatTensortimestep: typing.Union[float, torch.FloatTensor]sample: FloatTensors_churn: float = 0.0s_tmin: float = 0.0s_tmax: float = infs_noise: float = 1.0generator: typing.Optional[torch.Generator] = Nonereturn_dict: bool = True ) → FlowMatchHeunDiscreteSchedulerOutput or tuple
参数
- model_output (
torch.FloatTensor) — 学习到的扩散模型的直接输出。 - timestep (
float或torch.FloatTensor) — 扩散链中的当前离散时间步。 - sample (
torch.FloatTensor) — 扩散过程生成的样本的当前实例。 - s_churn (
float) — 控制采样过程中添加噪声量的随机性参数。值越高,随机性越强。 - s_tmin (
float) — 应用随机性的最小时间步阈值。仅当时间步大于该值时,才会添加噪声。 - s_tmax (
float) — 应用随机性的最大时间步阈值。仅当时间步低于此值时,才会添加噪声。 - s_noise (
float,默认为 1.0) — 添加到样本的噪声的缩放因子。 - generator (
torch.Generator,可选) — 随机数生成器。 - return_dict (
bool) — 是否返回FlowMatchHeunDiscreteSchedulerOutput元组。
返回值
FlowMatchHeunDiscreteSchedulerOutput 或 tuple
If return_dict is True,
FlowMatchHeunDiscreteSchedulerOutput is returned,
otherwise a tuple is returned where the first element is the sample tensor.
通过逆向 SDE 预测上一时间步的样本。此函数将扩散过程从学习到的模型输出(通常是预测的噪声)进行传播。