Struct EmbeddingFuncOptions#
Defined inFile embedding.h
Struct Documentation#
- structEmbeddingFuncOptions#
Options for
torch::nn::functional::embedding.Example:
namespaceF=torch::nn::functional;F::embedding(input,weight,F::EmbeddingFuncOptions().norm_type(2.5).scale_grad_by_freq(true).sparse(true));
Public Functions
- inlineautopadding_idx(conststd::optional<int64_t>&new_padding_idx)->decltype(*this)#
If specified, the entries at
padding_idxdo not contribute to the gradient; therefore, the embedding vector atpadding_idxis not updated during training, i.e.it remains as a fixed “pad”.
- inlineautopadding_idx(std::optional<int64_t>&&new_padding_idx)->decltype(*this)#
- inlineconststd::optional<int64_t>&padding_idx()constnoexcept#
- inlinestd::optional<int64_t>&padding_idx()noexcept#
- inlineautomax_norm(conststd::optional<double>&new_max_norm)->decltype(*this)#
If given, each embedding vector with norm larger than
max_normis renormalized to have normmax_norm.
- inlineautomax_norm(std::optional<double>&&new_max_norm)->decltype(*this)#
- inlineconststd::optional<double>&max_norm()constnoexcept#
- inlinestd::optional<double>&max_norm()noexcept#
- inlineautonorm_type(constdouble&new_norm_type)->decltype(*this)#
The p of the p-norm to compute for the
max_normoption. Default2.
- inlineautonorm_type(double&&new_norm_type)->decltype(*this)#
- inlineconstdouble&norm_type()constnoexcept#
- inlinedouble&norm_type()noexcept#
- inlineautoscale_grad_by_freq(constbool&new_scale_grad_by_freq)->decltype(*this)#
If given, this will scale gradients by the inverse of frequency of the words in the mini-batch.
Default
false.
- inlineautoscale_grad_by_freq(bool&&new_scale_grad_by_freq)->decltype(*this)#
- inlineconstbool&scale_grad_by_freq()constnoexcept#
- inlinebool&scale_grad_by_freq()noexcept#
- inlineautosparse(constbool&new_sparse)->decltype(*this)#
If
true, gradient w.r.t.weightmatrix will be a sparse tensor.
- inlineautosparse(bool&&new_sparse)->decltype(*this)#
- inlineconstbool&sparse()constnoexcept#
- inlinebool&sparse()noexcept#
- inlineautopadding_idx(conststd::optional<int64_t>&new_padding_idx)->decltype(*this)#