# AutoencoderOobleck

Mô hình biến thể tự mã hóa (VAE) Oobleck với tổn thất KL được giới thiệu trong [Stability-AI/stable-audio-tools](https://github.com/Stability-AI/stable-audio-tools) và [Stable Audio Open](https://huggingface.co/papers/2407.14358) của Stability AI. Mô hình này được sử dụng trong 🤗 Diffusers để mã hóa dạng sóng âm thanh thành các ẩn (latents) và giải mã các biểu diễn ẩn thành dạng sóng âm thanh.

Tóm tắt từ bài báo là:

*Các mô hình sinh mở đóng vai trò thiết yếu đối với cộng đồng, cho phép tinh chỉnh và làm cơ sở so sánh khi giới thiệu các mô hình mới. Tuy nhiên, hầu hết các mô hình văn bản sang âm thanh hiện tại đều là riêng tư và không cho phép các nghệ sĩ và nhà nghiên cứu xây dựng dựa trên đó. Ở đây, chúng tôi mô tả kiến trúc và quy trình huấn luyện của một mô hình văn bản sang âm thanh mã nguồn mở mới, được huấn luyện bằng dữ liệu Creative Commons. Đánh giá của chúng tôi cho thấy hiệu suất của mô hình có tính cạnh tranh với mức tiên tiến nhất trên nhiều chỉ số. Đáng chú ý, kết quả FDopenl3 được báo cáo (đo lường tính chân thực của các bản tổng hợp) cho thấy tiềm năng của mô hình trong việc tổng hợp âm thanh stereo chất lượng cao ở 44.1kHz.*

## AutoencoderOobleck[[diffusers.AutoencoderOobleck]]

#### diffusers.AutoencoderOobleck[[diffusers.AutoencoderOobleck]]

```python
diffusers.AutoencoderOobleck(encoder_hidden_size = 128, downsampling_ratios = [2, 4, 4, 8, 8], channel_multiples = [1, 2, 4, 8, 16], decoder_channels = 128, decoder_input_channels = 64, audio_channels = 2, sampling_rate = 44100)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_oobleck.py#L294)

**Tham số:**

encoder_hidden_size (`int`, *optional*, mặc định là 128) : Kích thước chiều biểu diễn trung gian cho bộ mã hóa.

downsampling_ratios (`list[int]`, *optional*, mặc định là `[2, 4, 4, 8, 8]`) : Tỷ lệ hạ mẫu trong encoder. Các tỷ lệ này được sử dụng theo thứ tự ngược lại để tăng mẫu trong decoder.

channel_multiples (`list[int]`, *tùy chọn*, mặc định là `[1, 2, 4, 8, 16]`) : Các bội số được sử dụng để xác định kích thước ẩn của các lớp ẩn.

decoder_channels (`int`, *tuỳ chọn*, mặc định là 128) : Kích thước chiều biểu diễn trung gian cho bộ giải mã.

decoder_input_channels (`int`, *optional*, mặc định là 64) : Kích thước đầu vào cho bộ giải mã. Tương ứng với kích thước ẩn.

audio_channels (`int`, *tuỳ chọn*, mặc định là 2) : Số kênh trong dữ liệu âm thanh. 1 cho mono hoặc 2 cho stereo.

sampling_rate (`int`, *optional*, mặc định là 44100) : Tốc độ lấy mẫu mà tại đó dạng sóng âm thanh cần được số hóa, được biểu diễn bằng hertz (Hz).

Một autoencoder để mã hóa dạng sóng thành các ẩn và giải mã các biểu diễn ẩn thành dạng sóng. Được giới thiệu lần đầu trong Stable Audio.

Mô hình này kế thừa từ [ModelMixin](/docs/diffusers/v0.43.0/vi/api/models/overview#diffusers.ModelMixin). Hãy xem tài liệu của lớp cha để biết các phương thức chung được triển khai cho tất cả các mô hình (chẳng hạn như tải xuống hoặc lưu trữ).

#### decode[[diffusers.AutoencoderOobleck.decode]]

```python
decode(z: FloatTensor, return_dict: bool = True, generator = None)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_oobleck.py#L488)

**Tham số:**

z (`torch.Tensor`) : Lô đầu vào của các vector ẩn.

return_dict (`bool`, *tùy chọn*, mặc định là `True`) : Có nên trả về một `~models.vae.OobleckDecoderOutput` thay vì một tuple thông thường hay không.

**Trả về:** `~models.vae.OobleckDecoderOutput` hoặc `tuple`

If return_dict is True, a `~models.vae.OobleckDecoderOutput` is returned, otherwise a plain `tuple` is returned.

Giải mã một lô ảnh.

#### encode[[diffusers.AutoencoderOobleck.encode]]

```python
encode(x: Tensor, return_dict: bool = True)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_oobleck.py#L377)

**Tham số:**

x (`torch.Tensor`) : Lô đầu vào của các hình ảnh.

return_dict (`bool`, *tùy chọn*, mặc định là `True`) : Có nên trả về một `~models.autoencoder_kl.AutoencoderKLOutput` thay vì một tuple thông thường hay không.

**Trả về:**

Các biểu diễn ẩn của các hình ảnh đã được mã hóa. Nếu `return_dict` là True, một `~models.autoencoder_kl.AutoencoderKLOutput` sẽ được trả về, ngược lại một `tuple` thông thường sẽ được trả về.

Mã hóa một lô ảnh thành các biến ẩn.

#### forward[[diffusers.AutoencoderOobleck.forward]]

```python
forward(sample: Tensor, sample_posterior: bool = False, return_dict: bool = True, generator: typing.Optional[torch.Generator] = None)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_oobleck.py#L517)

**Tham số:**

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

sample_posterior (`bool`, *tùy chọn*, mặc định là `False`) : Có lấy mẫu từ phân phối hậu nghiệm hay không.

return_dict (`bool`, *tùy chọn*, mặc định là `True`) : Có nên trả về một `OobleckDecoderOutput` thay vì một tuple thông thường hay không.

generator (`torch.Generator`, *tùy chọn*) : Một [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) để làm cho việc lấy mẫu trở nên tất định.

**Trả về:** `~models.vae.OobleckDecoderOutput` hoặc `tuple`

Nếu `return_dict` là True, một `~models.vae.OobleckDecoderOutput` sẽ được trả về, ngược lại một `tuple` thông thường sẽ được trả về.

## OobleckDecoderOutput[[diffusers.models.autoencoders.autoencoder_oobleck.OobleckDecoderOutput]]

#### diffusers.models.autoencoders.autoencoder_oobleck.OobleckDecoderOutput[[diffusers.models.autoencoders.autoencoder_oobleck.OobleckDecoderOutput]]

```python
diffusers.models.autoencoders.autoencoder_oobleck.OobleckDecoderOutput(sample: Tensor)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_oobleck.py#L202)

**Tham số:**

sample (`torch.Tensor` có hình dạng `(batch_size, audio_channels, sequence_length)`) : Mẫu đầu ra đã giải mã từ lớp cuối cùng của mô hình.

Đầu ra của phương pháp giải mã.

## AutoencoderOobleckOutput[[diffusers.models.autoencoders.autoencoder_oobleck.AutoencoderOobleckOutput]]

#### diffusers.models.autoencoders.autoencoder_oobleck.AutoencoderOobleckOutput[[diffusers.models.autoencoders.autoencoder_oobleck.AutoencoderOobleckOutput]]

```python
diffusers.models.autoencoders.autoencoder_oobleck.AutoencoderOobleckOutput(latent_dist: OobleckDiagonalGaussianDistribution)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_oobleck.py#L187)

**Tham số:**

latent_dist (`OobleckDiagonalGaussianDistribution`) : Đầu ra mã hóa của `Encoder` được biểu diễn dưới dạng trung bình và độ lệch chuẩn của `OobleckDiagonalGaussianDistribution`. `OobleckDiagonalGaussianDistribution` cho phép lấy mẫu các biến ẩn từ phân phối này.

Đầu ra của phương pháp mã hóa của AutoencoderOobleck.

