13 #ifndef MLPACK_METHODS_ANN_LAYER_LOOKUP_HPP 14 #define MLPACK_METHODS_ANN_LAYER_LOOKUP_HPP 38 typename InputDataType = arma::mat,
39 typename OutputDataType = arma::mat
50 Lookup(
const size_t vocabSize = 0,
const size_t embeddingSize = 0);
60 void Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output);
73 const arma::Mat<eT>& gy,
84 void Gradient(
const arma::Mat<eT>& input,
85 const arma::Mat<eT>& error,
86 arma::Mat<eT>& gradient);
89 OutputDataType
const&
Parameters()
const {
return weights; }
99 OutputDataType
const&
Delta()
const {
return delta; }
101 OutputDataType&
Delta() {
return delta; }
104 OutputDataType
const&
Gradient()
const {
return gradient; }
117 template<
typename Archive>
118 void serialize(Archive& ar,
const uint32_t );
125 size_t embeddingSize;
128 OutputDataType weights;
131 OutputDataType delta;
134 OutputDataType gradient;
137 OutputDataType outputParameter;
141 template<
typename MatType = arma::mat>
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: lookup.hpp:94
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: lookup_impl.hpp:87
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t EmbeddingSize() const
Get the length of each embedding vector.
Definition: lookup.hpp:112
size_t VocabSize() const
Get the size of the vocabulary.
Definition: lookup.hpp:109
OutputDataType & Parameters()
Modify the parameters.
Definition: lookup.hpp:91
OutputDataType & Gradient()
Modify the gradient.
Definition: lookup.hpp:106
The Lookup class stores word embeddings and retrieves them using tokens.
Definition: lookup.hpp:41
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 activ...
Definition: lookup_impl.hpp:34
Lookup(const size_t vocabSize=0, const size_t embeddingSize=0)
Create the Lookup object using the specified vocabulary and embedding size.
Definition: lookup_impl.hpp:23
OutputDataType const & Delta() const
Get the delta.
Definition: lookup.hpp:99
OutputDataType const & Gradient() const
Get the gradient.
Definition: lookup.hpp:104
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 backw...
Definition: lookup_impl.hpp:54
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: lookup.hpp:96
OutputDataType & Delta()
Modify the delta.
Definition: lookup.hpp:101
OutputDataType const & Parameters() const
Get the parameters.
Definition: lookup.hpp:89