Shortcuts

Struct TransformerOptions

Page Contents

Struct Documentation

struct TransformerOptions

Options for the Transformer module.

Example:

TransformerOptions options;
TransformerOptions options(16, 4);
auto options = TransformerOptions().d_model(4).nhead(2).dropout(0.0);

Public Functions

TransformerOptions() = default
TransformerOptions(int64_t d_model, int64_t nhead)
TransformerOptions(int64_t d_model, int64_t nhead, int64_t num_encoder_layers, int64_t num_decoder_layers)
inline auto d_model(const int64_t &new_d_model) -> decltype(*this)

the number of expected features in the encoder/decoder inputs (default=512)

inline auto d_model(int64_t &&new_d_model) -> decltype(*this)
inline const int64_t &d_model() const noexcept
inline int64_t &d_model() noexcept
inline auto nhead(const int64_t &new_nhead) -> decltype(*this)

the number of heads in the multiheadattention models (default=8)

inline auto nhead(int64_t &&new_nhead) -> decltype(*this)
inline const int64_t &nhead() const noexcept
inline int64_t &nhead() noexcept
inline auto num_encoder_layers(const int64_t &new_num_encoder_layers) -> decltype(*this)

the number of sub-encoder-layers in the encoder (default=6)

inline auto num_encoder_layers(int64_t &&new_num_encoder_layers) -> decltype(*this)
inline const int64_t &num_encoder_layers() const noexcept
inline int64_t &num_encoder_layers() noexcept
inline auto num_decoder_layers(const int64_t &new_num_decoder_layers) -> decltype(*this)

the number of sub-decoder-layers in the decoder (default=6)

inline auto num_decoder_layers(int64_t &&new_num_decoder_layers) -> decltype(*this)
inline const int64_t &num_decoder_layers() const noexcept
inline int64_t &num_decoder_layers() noexcept
inline auto dim_feedforward(const int64_t &new_dim_feedforward) -> decltype(*this)

the dimension of the feedforward network model (default=2048)

inline auto dim_feedforward(int64_t &&new_dim_feedforward) -> decltype(*this)
inline const int64_t &dim_feedforward() const noexcept
inline int64_t &dim_feedforward() noexcept
inline auto dropout(const double &new_dropout) -> decltype(*this)

the dropout value (default=0.1)

inline auto dropout(double &&new_dropout) -> decltype(*this)
inline const double &dropout() const noexcept
inline double &dropout() noexcept
inline auto activation(const activation_t &new_activation) -> decltype(*this)

the activation function of encoder/decoder intermediate layer (default=torch::kReLU)

inline auto activation(activation_t &&new_activation) -> decltype(*this)
inline const activation_t &activation() const noexcept
inline activation_t &activation() noexcept
inline auto custom_encoder(const AnyModule &new_custom_encoder) -> decltype(*this)

custom encoder (default=None)

inline auto custom_encoder(AnyModule &&new_custom_encoder) -> decltype(*this)
inline const AnyModule &custom_encoder() const noexcept
inline AnyModule &custom_encoder() noexcept
inline auto custom_decoder(const AnyModule &new_custom_decoder) -> decltype(*this)

custom decoder (default=None)

inline auto custom_decoder(AnyModule &&new_custom_decoder) -> decltype(*this)
inline const AnyModule &custom_decoder() const noexcept
inline AnyModule &custom_decoder() noexcept

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources