Shortcuts

Struct MultiheadAttentionOptions

Page Contents

Struct Documentation

struct torch::nn::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)
auto embed_dim(const int64_t &new_embed_dim) -> decltype(*this)

total dimension of the model.

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

parallel attention heads.

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

a Dropout layer on attn_output_weights. Default: 0.0.

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

add bias as module parameter. Default: true.

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

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

auto add_bias_kv(bool &&new_add_bias_kv) -> decltype(*this)
const bool &add_bias_kv() const noexcept
bool &add_bias_kv() noexcept
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.

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

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

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

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

auto vdim(int64_t &&new_vdim) -> decltype(*this)
const int64_t &vdim() const noexcept
int64_t &vdim() 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