Diffusers 文件

FlowMatchHeun離散排程器

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

FlowMatchHeun離散排程器

FlowMatchHeunDiscreteScheduler 基於 EDM 中引入的流匹配取樣。

FlowMatchHeun離散排程器

class diffusers.FlowMatchHeunDiscreteScheduler

< >

( 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) — 時間步排程器的偏移值。

Heun 排程器。

此模型繼承自 SchedulerMixinConfigMixin。檢視超類文件以瞭解庫為所有排程器(例如載入和儲存)實現的通用方法。

scale_noise

< >

( sample: FloatTensor timestep: typing.Union[float, torch.FloatTensor] noise: typing.Optional[torch.FloatTensor] = None ) torch.FloatTensor

引數

  • sample (torch.FloatTensor) — 輸入樣本。
  • timestep (int, 可選) — 擴散鏈中的當前時間步。

返回

torch.FloatTensor

一個縮放後的輸入樣本。

流匹配中的前向過程

set_begin_index

< >

( begin_index: int = 0 )

引數

  • begin_index (int) — 排程器的起始索引。

設定排程器的起始索引。此函式應在推理之前從管道中執行。

set_timesteps

< >

( num_inference_steps: int device: typing.Union[str, torch.device] = None )

引數

  • num_inference_steps (int) — 使用預訓練模型生成樣本時的擴散步數。
  • device (strtorch.device, 可選) — 時間步應移動到的裝置。如果為 None,則時間步不移動。

設定用於擴散鏈的離散時間步(在推理之前執行)。

步驟

< >

( 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 ) FlowMatchHeunDiscreteSchedulerOutputtuple

引數

  • 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) — 是否返回 FlowMatchHeunDiscreteSchedulerOutput 元組。

返回

FlowMatchHeunDiscreteSchedulerOutputtuple

如果 return_dict 為 True,則返回 FlowMatchHeunDiscreteSchedulerOutput,否則返回一個元組,其中第一個元素是樣本張量。

透過逆轉 SDE 預測前一個時間步的樣本。此函式從學習到的模型輸出(通常是預測的噪聲)傳播擴散過程。

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.