speechbrain.lobes.models.L2I 模块
该文件实现了必要的类和函数,以实现从https://arxiv.org/abs/2202.11479v2中提出的Listen-to-Interpret (L2I)解释方法。
作者 * 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激活的卷积层
- Parameters:
Example
>>> 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解码器
Example
>>> 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初始化应用于网络权重。
- Parameters:
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激活,针对对数谱进行了优化。
- Parameters:
Example
>>> 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激活之上实现了一个线性分类器
Example
>>> 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编码器
Example
>>> 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域上的显著性图。
Example
>>> 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激活以创建显著性图
Example
>>> 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])