HDemucs¶
- class torchaudio.models.HDemucs(sources: List[str], audio_channels: int = 2, channels: int = 48, growth: int = 2, nfft: int = 4096, depth: int = 6, freq_emb: float = 0.2, emb_scale: int = 10, emb_smooth: bool = True, kernel_size: int = 8, time_stride: int = 2, stride: int = 4, context: int = 1, context_enc: int = 0, norm_starts: int = 4, norm_groups: int = 4, dconv_depth: int = 2, dconv_comp: int = 4, dconv_attn: int = 4, dconv_lstm: int = 4, dconv_init: float = 0.0001)[source]¶
来自 Hybrid Spectrogram and Waveform Source Separation [Défossez, 2021] 的 Hybrid Demucs 模型。
另请参阅
torchaudio.pipelines.SourceSeparationBundle
:带有预训练模型的源分离 pipeline。
- 参数:
sources (List[str]) – 源名称列表。列表可包含以下源选项:[
"bass"
,"drums"
,"other"
,"mixture"
,"vocals"
]。audio_channels (int, optional) – 输入/输出音频通道数。(默认值: 2)
channels (int, optional) – 初始隐藏通道数。(默认值: 48)
growth (int, optional) – 在每个层增加隐藏通道数的因子。(默认值: 2)
nfft (int, optional) – FFT bins 的数量。请注意,更改此值需要仔细计算各种形状参数,对于混合模型,这不会直接生效。(默认值: 4096)
depth (int, optional) – 编码器和解码器中的层数。(默认值: 6)
freq_emb (float, optional) – 如果大于 0,则在第一个频率层后添加频率嵌入,实际值控制嵌入的权重。(默认值: 0.2)
emb_scale (int, optional) – 相当于缩放嵌入学习率。(默认值: 10)
emb_smooth (bool, optional) – 使用平滑嵌入(相对于频率)初始化嵌入。(默认值:
True
)kernel_size (int, optional) – 编码器和解码器层的 kernel_size。(默认值: 8)
time_stride (int, optional) – 合并后的最终时间层的 stride。(默认值: 2)
stride (int, optional) – 编码器和解码器层的 stride。(默认值: 4)
context (int, optional) – 解码器中 1x1 卷积的上下文。(默认值: 4)
context_enc (int, optional) – 编码器中 1x1 卷积的上下文。(默认值: 0)
norm_starts (int, optional) – 开始使用组归一化的层。解码器层按相反顺序编号。(默认值: 4)
norm_groups (int, optional) – 组归一化的组数。(默认值: 4)
dconv_depth (int, optional) – 残差 DConv 分支的深度。(默认值: 2)
dconv_comp (int, optional) – DConv 分支的压缩因子。(默认值: 4)
dconv_attn (int, optional) – 从此层开始在 DConv 分支中添加注意力层。(默认值: 4)
dconv_lstm (int, optional) – 从此层开始在 DConv 分支中添加一个 LSTM 层。(默认值: 4)
dconv_init (float, optional) – DConv 分支 LayerScale 的初始比例。(默认值: 1e-4)
- 使用
HDemucs
的教程
方法¶
forward¶
- HDemucs.forward(input: Tensor)[source]¶
HDemucs 前向传播调用
- 参数:
input (torch.Tensor) – 输入混合张量,形状为 (batch_size, channel, num_frames)
- 返回:
- 张量
输出张量,拆分为源,形状为 (batch_size, num_sources, channel, num_frames)
工厂函数¶
构建低 nfft (1024) 版本的 |
|
构建中等 nfft (2048) 版本的 |
|
构建高 nfft (4096) 版本的 |