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