speechbrain.lobes.models.L2I 模块
此文件实现了实现 Listen-to-Interpret (L2I) 解释方法所需的类和函数,该方法来自 https://arxiv.org/abs/2202.11479v2
作者 * Cem Subakan 2022 * Francesco Paissan 2022
摘要
类
此类根据分类器表示,估计 STFT 域上的显著性图。 |
|
此类使用 L2I 框架估计 NMF 激活以创建显著性图 |
|
此类实现了 NMF 解码器 |
|
此类使用卷积网络实现了 NMF 编码器 |
|
卷积层,用于从分类器表示中估计 NMF 激活 |
|
卷积层,用于从分类器表示中估计 NMF 激活,针对对数频谱进行了优化。 |
|
此类在 NMF 激活之上实现了一个线性分类器 |
函数
对网络权重应用 Xavier 初始化。 |
参考
- class speechbrain.lobes.models.L2I.Psi(n_comp=100, T=431, in_emb_dims=[2048, 1024, 512])[source]
基类:
Module
卷积层,用于从分类器表示中估计 NMF 激活
- 参数:
示例
>>> inp = [torch.ones(2, 150, 6, 2), torch.ones(2, 100, 6, 2), torch.ones(2, 50, 12, 5)] >>> psi = Psi(n_comp=100, T=120, in_emb_dims=[150, 100, 50]) >>> h = psi(inp) >>> print(h.shape) torch.Size([2, 100, 120])
- class speechbrain.lobes.models.L2I.NMFDecoderAudio(n_comp=100, n_freq=513, device='cuda')[source]
基类:
Module
此类实现了 NMF 解码器
示例
>>> NMF_dec = NMFDecoderAudio(20, 210, device='cpu') >>> H = torch.rand(1, 20, 150) >>> Xhat = NMF_dec.forward(H) >>> print(Xhat.shape) torch.Size([1, 210, 150])
- speechbrain.lobes.models.L2I.weights_init(m)[source]
对网络权重应用 Xavier 初始化。
- 参数:
m (nn.Module) – 要初始化的模块。
- class speechbrain.lobes.models.L2I.PsiOptimized(dim=128, K=100, numclasses=50, use_adapter=False, adapter_reduce_dim=True)[source]
基类:
Module
卷积层,用于从分类器表示中估计 NMF 激活,针对对数频谱进行了优化。
- 参数:
示例
>>> inp = torch.randn(1, 256, 26, 32) >>> psi = PsiOptimized(dim=256, K=100, use_adapter=False, adapter_reduce_dim=False) >>> h, inp_ad= psi(inp) >>> print(h.shape, inp_ad.shape) torch.Size([1, 1, 417, 100]) torch.Size([1, 256, 26, 32])
- class speechbrain.lobes.models.L2I.Theta(n_comp=100, T=431, num_classes=50)[source]
基类:
Module
此类在 NMF 激活之上实现了一个线性分类器
示例
>>> theta = Theta(30, 120, 50) >>> H = torch.rand(1, 30, 120) >>> c_hat = theta.forward(H) >>> print(c_hat.shape) torch.Size([1, 50])
- class speechbrain.lobes.models.L2I.NMFEncoder(n_freq, n_comp)[source]
基类:
Module
此类使用卷积网络实现了 NMF 编码器
示例
>>> nmfencoder = NMFEncoder(513, 100) >>> X = torch.rand(1, 513, 240) >>> Hhat = nmfencoder(X) >>> print(Hhat.shape) torch.Size([1, 100, 240])
- class speechbrain.lobes.models.L2I.CNN14PSI_stft(dim=128, K=100)[source]
基类:
Module
此类根据分类器表示,估计 STFT 域上的显著性图。
示例
>>> from speechbrain.lobes.models.Cnn14 import Cnn14 >>> classifier_embedder = Cnn14(mel_bins=80, emb_dim=2048, return_reps=True) >>> x = torch.randn(2, 201, 80) >>> _, hs = classifier_embedder(x) >>> psimodel = CNN14PSI_stft(2048, 20) >>> xhat = psimodel.forward(hs) >>> print(xhat.shape) torch.Size([2, 20, 207])
- class speechbrain.lobes.models.L2I.CNN14PSI_stft_2d(dim=128, K=100)[source]
基类:
Module
此类使用 L2I 框架估计 NMF 激活以创建显著性图
示例
>>> from speechbrain.lobes.models.Cnn14 import Cnn14 >>> classifier_embedder = Cnn14(mel_bins=80, emb_dim=2048, return_reps=True) >>> x = torch.randn(2, 201, 80) >>> _, hs = classifier_embedder(x) >>> psimodel = CNN14PSI_stft_2d(2048, 20) >>> xhat = psimodel.forward(hs) >>> print(xhat.shape) torch.Size([2, 20, 207])