Rate this Page

Struct MultiheadAttentionOptions#

Page Contents

Struct Documentation#

struct MultiheadAttentionOptions#

Options for the MultiheadAttention module.

Example:

MultiheadAttention model(MultiheadAttentionOptions(20, 10).bias(false));

Public Functions

MultiheadAttentionOptions(int64_t embed_dim, int64_t num_heads)#
inline auto embed_dim(const int64_t &new_embed_dim) -> decltype(*this)#

total dimension of the model.

inline auto embed_dim(int64_t &&new_embed_dim) -> decltype(*this)#
inline const int64_t &embed_dim() const noexcept#
inline int64_t &embed_dim() noexcept#
inline auto num_heads(const int64_t &new_num_heads) -> decltype(*this)#

parallel attention heads.

inline auto num_heads(int64_t &&new_num_heads) -> decltype(*this)#
inline const int64_t &num_heads() const noexcept#
inline int64_t &num_heads() noexcept#
inline auto dropout(const double &new_dropout) -> decltype(*this)#

a Dropout layer on attn_output_weights. Default: 0.0.

inline auto dropout(double &&new_dropout) -> decltype(*this)#
inline const double &dropout() const noexcept#
inline double &dropout() noexcept#
inline auto bias(const bool &new_bias) -> decltype(*this)#

add bias as module parameter. Default: true.

inline auto bias(bool &&new_bias) -> decltype(*this)#
inline const bool &bias() const noexcept#
inline bool &bias() noexcept#
inline auto add_bias_kv(const bool &new_add_bias_kv) -> decltype(*this)#

add bias to the key and value sequences at dim=0.

inline auto add_bias_kv(bool &&new_add_bias_kv) -> decltype(*this)#
inline const bool &add_bias_kv() const noexcept#
inline bool &add_bias_kv() noexcept#
inline auto add_zero_attn(const bool &new_add_zero_attn) -> decltype(*this)#

add a new batch of zeros to the key and value sequences at dim=1.

inline auto add_zero_attn(bool &&new_add_zero_attn) -> decltype(*this)#
inline const bool &add_zero_attn() const noexcept#
inline bool &add_zero_attn() noexcept#
inline auto kdim(const int64_t &new_kdim) -> decltype(*this)#

total number of features in key. Default: std::nullopt.

inline auto kdim(int64_t &&new_kdim) -> decltype(*this)#
inline const int64_t &kdim() const noexcept#
inline int64_t &kdim() noexcept#
inline auto vdim(const int64_t &new_vdim) -> decltype(*this)#

total number of features in key. Default: std::nullopt.

inline auto vdim(int64_t &&new_vdim) -> decltype(*this)#
inline const int64_t &vdim() const noexcept#
inline int64_t &vdim() noexcept#