speechbrain.lobes.models.transformer.TransformerSE 模块
用于SE的CNN Transformer模型,采用SpeechBrain风格。
作者 * 廖建峰 2020
摘要
类:
这是一个带有CNN预编码器的变压器模型的实现,用于SE。 |
参考
- 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]
基础类:
TransformerInterface这是使用CNN预编码器实现的SE变压器模型。
- Parameters:
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) – 丢弃率值(默认=0.1)。
activation (torch 类) – 中间层的激活函数(默认=LeakyReLU)。
因果 (bool) – 如果为True,则启用因果设置,模型被禁止看到未来的帧(默认=True)。
custom_emb_module (torch class) – 在transformer模型之前处理输入特征的模块。
normalize_before (bool) – 是否在每一层之前进行归一化。
Example
>>> src = torch.rand([8, 120, 256]) >>> net = CNNTransformerSE(d_model=256, output_size=257) >>> out = net(src) >>> out.shape torch.Size([8, 120, 257])