用法:
class torch.nn.TransformerEncoder(encoder_layer, num_layers, norm=None)
encoder_layer-TransformerEncoderLayer() 类的实例(必需)。
num_layers-编码器中sub-encoder-layers 的数量(必需)。
norm-层标准化组件(可选)。
TransformerEncoder 是 N 个编码器层的堆栈
- 例子::
>>> encoder_layer = nn.TransformerEncoderLayer(d_model=512, nhead=8) >>> transformer_encoder = nn.TransformerEncoder(encoder_layer, num_layers=6) >>> src = torch.rand(10, 32, 512) >>> out = transformer_encoder(src)
参数:
相关用法
- Python torch.nn.TransformerEncoderLayer用法及代码示例
- Python torch.nn.Transformer用法及代码示例
- Python torch.nn.Transformer.forward用法及代码示例
- Python torch.nn.TransformerDecoderLayer用法及代码示例
- Python torch.nn.TransformerDecoder用法及代码示例
- Python torch.nn.TripletMarginWithDistanceLoss用法及代码示例
- Python torch.nn.TripletMarginLoss用法及代码示例
- Python torch.nn.Tanhshrink用法及代码示例
- Python torch.nn.Tanh用法及代码示例
- Python torch.nn.Threshold用法及代码示例
- Python torch.nn.InstanceNorm3d用法及代码示例
- Python torch.nn.quantized.dynamic.LSTM用法及代码示例
- Python torch.nn.EmbeddingBag用法及代码示例
- Python torch.nn.Module.register_forward_hook用法及代码示例
- Python torch.nn.AvgPool2d用法及代码示例
- Python torch.nn.PixelShuffle用法及代码示例
- Python torch.nn.CELU用法及代码示例
- Python torch.nn.Hardsigmoid用法及代码示例
- Python torch.nn.functional.conv1d用法及代码示例
- Python torch.nn.Identity用法及代码示例
注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.nn.TransformerEncoder。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。