Positional Encoding injects some information about the relative or absolute position of the tokens in the sequence. More...
Public Member Functions | |
PositionalEncoding () | |
Create PositionalEncoding object. More... | |
PositionalEncoding (const size_t embedDim, const size_t maxSequenceLength) | |
Create the PositionalEncoding layer object using the specified parameters. More... | |
template < typename eT > | |
void | Backward (const arma::Mat< eT > &, const arma::Mat< eT > &gy, arma::Mat< eT > &g) |
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards trough f. More... | |
OutputDataType const & | Delta () const |
Get the delta. More... | |
OutputDataType & | Delta () |
Modify the delta. More... | |
InputDataType const & | Encoding () const |
Get the positional encoding vector. More... | |
template < typename eT > | |
void | Forward (const arma::Mat< eT > &input, arma::Mat< eT > &output) |
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f. More... | |
InputDataType const & | InputParameter () const |
Get the input parameter. More... | |
InputDataType & | InputParameter () |
Modify the input parameter. More... | |
size_t | InputShape () const |
OutputDataType const & | OutputParameter () const |
Get the output parameter. More... | |
OutputDataType & | OutputParameter () |
Modify the output parameter. More... | |
template < typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the layer. More... | |
Positional Encoding injects some information about the relative or absolute position of the tokens in the sequence.
The input and the output have the same shape: (embedDim * maxSequenceLength, batchSize)
. The embeddings are stored consequently.
InputDataType | Type of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
OutputDataType | Type of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
Definition at line 37 of file positional_encoding.hpp.
Create PositionalEncoding object.
PositionalEncoding | ( | const size_t | embedDim, |
const size_t | maxSequenceLength | ||
) |
Create the PositionalEncoding layer object using the specified parameters.
embedDim | The length of the embedding vector. |
maxSequenceLength | Number of tokens in each sequence. |
void Backward | ( | const arma::Mat< eT > & | , |
const arma::Mat< eT > & | gy, | ||
arma::Mat< eT > & | g | ||
) |
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards trough f.
Using the results from the feed forward pass.
* | (input) The propagated input activation. |
gy | The backpropagated error. |
g | The calculated gradient. |
|
inline |
Get the delta.
Definition at line 89 of file positional_encoding.hpp.
|
inline |
Modify the delta.
Definition at line 91 of file positional_encoding.hpp.
|
inline |
Get the positional encoding vector.
Definition at line 94 of file positional_encoding.hpp.
void Forward | ( | const arma::Mat< eT > & | input, |
arma::Mat< eT > & | output | ||
) |
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f.
input | Input data used for evaluating the specified function. |
output | Resulting output activation. |
|
inline |
Get the input parameter.
Definition at line 79 of file positional_encoding.hpp.
|
inline |
Modify the input parameter.
Definition at line 81 of file positional_encoding.hpp.
|
inline |
Definition at line 96 of file positional_encoding.hpp.
References PositionalEncoding< InputDataType, OutputDataType >::serialize().
|
inline |
Get the output parameter.
Definition at line 84 of file positional_encoding.hpp.
|
inline |
Modify the output parameter.
Definition at line 86 of file positional_encoding.hpp.
void serialize | ( | Archive & | ar, |
const uint32_t | |||
) |
Serialize the layer.
Referenced by PositionalEncoding< InputDataType, OutputDataType >::InputShape().