Rate this Page

Class TransformerEncoderImpl#

Inheritance Relationships#

Base Type#

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 fortorch::nn::TransformerEncoder class 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 thisTransformerEncoder was constructed

ModuleListlayers=nullptr#

module list that contains all the encoder layers

AnyModulenorm#

optional normalization module

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 theFORWARD_HAS_DEFAULT_ARGS macro.

inlinevirtualunsignedint_forward_num_required_args()override#
inlinestd::vector<torch::nn::AnyValue>_forward_populate_default_args(std::vector<torch::nn::AnyValue>&&arguments)override#

Friends

friendstructtorch::nn::AnyModuleHolder