speechbrain.lobes.models.transformer.TransformerSE 模块
SpeechBrain 风格的用于 SE 的 CNN Transformer 模型。
作者 * Chien-Feng Liao 2020
摘要
类
这是用于 SE 的带有 CNN 预编码器的 transformer 模型的实现。 |
参考
- class speechbrain.lobes.models.transformer.TransformerSE.CNNTransformerSE(d_model, output_size, output_activation=<class 'torch.nn.modules.activation.ReLU'>, nhead=8, num_layers=8, d_ffn=512, dropout=0.1, activation=<class 'torch.nn.modules.activation.LeakyReLU'>, causal=True, custom_emb_module=None, normalize_before=False)[source]
-
这是用于 SE 的带有 CNN 预编码器的 transformer 模型的实现。
- 参数:
d_model (int) – 编码器输入中预期的特征数量。
output_size (int) – 输出层的神经元数量。
output_activation (torch class) – 输出层的激活函数(默认=ReLU)。
nhead (int) – 多头注意力模型中的头数(默认=8)。
num_layers (int) – transformer 中的子层数量(默认=8)。
d_ffn (int) – 编码器层中预期的特征数量(默认=512)。
dropout (int) – dropout 值(默认=0.1)。
activation (torch class) – 中间层的激活函数(默认=LeakyReLU)。
causal (bool) – 对于因果设置,为 True,模型不允许看到未来的帧(默认=True)。
custom_emb_module (torch class) – 在 transformer 模型之前处理输入特征的模块。
normalize_before (bool) – 是否在每个层之前进行归一化。
示例
>>> src = torch.rand([8, 120, 256]) >>> net = CNNTransformerSE(d_model=256, output_size=257) >>> out = net(src) >>> out.shape torch.Size([8, 120, 257])