Class TransformerEncoderImpl#
Defined inFile transformercoder.h
Inheritance Relationships#
Base Type#
publictorch::nn::Cloneable<TransformerEncoderImpl>(Template Class Cloneable)
Class Documentation#
- classTransformerEncoderImpl:publictorch::nn::Cloneable<TransformerEncoderImpl>#
TransformerEncoder module.
Seehttps://pytorch.org/docs/main/generated/torch.nn.TransformerEncoder.html to learn abouut the exact behavior of this encoder layer module.
See the documentation for
torch::nn::TransformerEncoderclass to learn what constructor arguments are supported for this encoder module.Example:
TransformerEncoderLayerencoderLayer(TransformerEncoderLayerOptions(512,8).dropout(0.1));TransformerEncoderencoder(TransformerEncoderOptions(encoderLayer,6).norm(LayerNorm(LayerNormOptions({2}))));
Public Functions
- inlineTransformerEncoderImpl(TransformerEncoderLayerencoder_layer,int64_tnum_layers)#
- explicitTransformerEncoderImpl(TransformerEncoderOptionsoptions_)#
- Tensorforward(constTensor&src,constTensor&src_mask={},constTensor&src_key_padding_mask={})#
- virtualvoidreset()override#
reset()must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.
- voidreset_parameters()#
Public Members
- TransformerEncoderOptionsoptions#
options with which this
TransformerEncoderwas constructed
- ModuleListlayers=nullptr#
module list that contains all the encoder layers
Protected Functions
- inlinevirtualbool_forward_has_default_args()override#
The following three functions allow a module with default arguments in its forward method to be used in aSequential module.
You should NEVER override these functions manually. Instead, you should use the
FORWARD_HAS_DEFAULT_ARGSmacro.
- inlinevirtualunsignedint_forward_num_required_args()override#
Friends
- friendstructtorch::nn::AnyModuleHolder
- inlineTransformerEncoderImpl(TransformerEncoderLayerencoder_layer,int64_tnum_layers)#