# FlowMatchHeunDiscreteScheduler

`FlowMatchHeunDiscreteScheduler` dựa trên phương pháp lấy mẫu flow-matching được giới thiệu trong [EDM](https://huggingface.co/papers/2403.03206).

## FlowMatchHeunDiscreteScheduler[[diffusers.FlowMatchHeunDiscreteScheduler]]

#### diffusers.FlowMatchHeunDiscreteScheduler[[diffusers.FlowMatchHeunDiscreteScheduler]]

```python
diffusers.FlowMatchHeunDiscreteScheduler(num_train_timesteps: int = 1000, shift: float = 1.0)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/schedulers/scheduling_flow_match_heun_discrete.py#L43)

**Tham số:**

num_train_timesteps (`int`, mặc định là 1000) : Số bước khuếch tán để huấn luyện mô hình.

shift (`float`, mặc định là 1.0) : Giá trị dịch cho lịch bước thời gian.

Trình lập lịch Heun.

Mô hình này kế thừa từ [SchedulerMixin](/docs/diffusers/v0.43.0/vi/api/schedulers/overview#diffusers.SchedulerMixin) và [ConfigMixin](/docs/diffusers/v0.43.0/vi/api/configuration#diffusers.ConfigMixin). Xem tài liệu của lớp cha để biết các phương thức chung mà thư viện triển khai cho tất cả các scheduler, chẳng hạn như tải và lưu.

#### index_for_timestep[[diffusers.FlowMatchHeunDiscreteScheduler.index_for_timestep]]

```python
index_for_timestep(timestep: typing.Union[float, torch.FloatTensor], schedule_timesteps: typing.Optional[torch.FloatTensor] = None)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/schedulers/scheduling_flow_match_heun_discrete.py#L179)

**Tham số:**

timestep (`float` hoặc `torch.FloatTensor`) : Giá trị bước thời gian cần tìm trong lịch trình.

schedule_timesteps (`torch.FloatTensor`, *tùy chọn*) : Lịch trình bước thời gian để tìm kiếm. Nếu là `None`, sẽ sử dụng `self.timesteps`.

**Trả về:** `int`

Chỉ số của bước thời gian trong lịch trình.

Tìm chỉ số của một bước thời gian (timestep) cho trước trong lịch trình bước thời gian.

#### scale_noise[[diffusers.FlowMatchHeunDiscreteScheduler.scale_noise]]

```python
scale_noise(sample: FloatTensor, timestep: typing.Union[float, torch.FloatTensor], noise: FloatTensor)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/schedulers/scheduling_flow_match_heun_discrete.py#L106)

**Tham số:**

sample (`torch.FloatTensor`) : Mẫu đầu vào.

timestep (`float` hoặc `torch.FloatTensor`) : Bước thời gian hiện tại trong chuỗi khuếch tán.

noise (`torch.FloatTensor`) : Tensor nhiễu.

**Trả về:** `torch.FloatTensor`

Một mẫu đầu vào đã được chuẩn hóa.

Quá trình tiến trong flow-matching

#### set_begin_index[[diffusers.FlowMatchHeunDiscreteScheduler.set_begin_index]]

```python
set_begin_index(begin_index: int = 0)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/schedulers/scheduling_flow_match_heun_discrete.py#L96)

**Tham số:**

begin_index (`int`, mặc định là `0`) : Chỉ số bắt đầu cho trình lập lịch.

Đặt chỉ số bắt đầu cho trình lập lịch. Hàm này nên được chạy từ pipeline trước khi suy luận.

#### set_timesteps[[diffusers.FlowMatchHeunDiscreteScheduler.set_timesteps]]

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

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/schedulers/scheduling_flow_match_heun_discrete.py#L139)

**Tham số:**

num_inference_steps (`int`) : Số bước khuếch tán được sử dụng khi tạo mẫu bằng một mô hình đã được huấn luyện trước.

device (`str` hoặc `torch.device`, *tuỳ chọn*) : Thiết bị mà các bước thời gian (timesteps) sẽ được chuyển đến. Nếu là `None`, các bước thời gian sẽ không được chuyển.

Đặt các bước thời gian rời rạc được sử dụng cho chuỗi khuếch tán (cần chạy trước khi suy luận).

#### bước[[diffusers.FlowMatchHeunDiscreteScheduler.step]]

```python
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.Generator] = None, return_dict: bool = True)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/schedulers/scheduling_flow_match_heun_discrete.py#L225)

**Tham số:**

model_output (`torch.FloatTensor`) : Đầu ra trực tiếp từ mô hình khuếch tán đã học.

timestep (`float` hoặc `torch.FloatTensor`) : Bước thời gian rời rạc hiện tại trong chuỗi khuếch tán.

sample (`torch.FloatTensor`) : Một bản sao mẫu hiện tại được tạo ra bởi quá trình khuếch tán.

s_churn (`float`) : Tham số ngẫu nhiên kiểm soát lượng nhiễu được thêm vào trong quá trình lấy mẫu. Giá trị cao hơn làm tăng tính ngẫu nhiên.

s_tmin (`float`) : Ngưỡng tối thiểu của bước thời gian để áp dụng tính ngẫu nhiên. Chỉ các bước thời gian lớn hơn giá trị này sẽ được thêm nhiễu.

s_tmax (`float`) : Ngưỡng bước thời gian tối đa để áp dụng tính ngẫu nhiên. Chỉ các bước thời gian có giá trị nhỏ hơn ngưỡng này mới được thêm nhiễu.

s_noise (`float`, mặc định là 1.0) : Hệ số tỷ lệ cho nhiễu được thêm vào mẫu.

generator (`torch.Generator`, *tùy chọn*) : Bộ tạo số ngẫu nhiên.

return_dict (`bool`) : Có nên trả về bộ `FlowMatchHeunDiscreteSchedulerOutput` hay không.

**Trả về:** `FlowMatchHeunDiscreteSchedulerOutput` hoặc `tuple`

If return_dict is `True`, `FlowMatchHeunDiscreteSchedulerOutput` is returned, otherwise a tuple is returned where the first element is the sample tensor.

Dự đoán mẫu từ bước thời gian trước đó bằng cách đảo ngược SDE. Hàm này lan truyền quá trình khuếch tán từ các đầu ra của mô hình đã học (thường nhất là nhiễu được dự đoán).

