26 #ifndef MLPACK_METHODS_ANN_LAYER_GRU_HPP 27 #define MLPACK_METHODS_ANN_LAYER_GRU_HPP 34 #include "../visitor/delta_visitor.hpp" 35 #include "../visitor/output_parameter_visitor.hpp" 55 typename InputDataType = arma::mat,
56 typename OutputDataType = arma::mat
71 GRU(
const size_t inSize,
73 const size_t rho = std::numeric_limits<size_t>::max());
83 void Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output);
96 const arma::Mat<eT>& gy,
106 template<
typename eT>
107 void Gradient(
const arma::Mat<eT>& input,
108 const arma::Mat<eT>& ,
117 void ResetCell(
const size_t size);
125 size_t Rho()
const {
return rho; }
127 size_t&
Rho() {
return rho; }
140 OutputDataType
const&
Delta()
const {
return delta; }
142 OutputDataType&
Delta() {
return delta; }
145 OutputDataType
const&
Gradient()
const {
return gradient; }
150 std::vector<LayerTypes<> >&
Model() {
return network; }
167 template<
typename Archive>
168 void serialize(Archive& ar,
const uint32_t );
184 OutputDataType weights;
187 LayerTypes<> input2GateModule;
190 LayerTypes<> output2GateModule;
193 LayerTypes<> outputHidden2GateModule;
196 LayerTypes<> inputGateModule;
199 LayerTypes<> hiddenStateModule;
202 LayerTypes<> forgetGateModule;
214 std::vector<LayerTypes<> > network;
226 std::list<arma::mat> outParameter;
232 std::list<arma::mat>::iterator prevOutput;
235 std::list<arma::mat>::iterator backIterator;
238 std::list<arma::mat>::iterator gradIterator;
247 OutputDataType delta;
250 OutputDataType gradient;
253 OutputDataType outputParameter;
DeleteVisitor executes the destructor of the instantiated object.
Definition: delete_visitor.hpp:27
OutputDataType & Parameters()
Modify the parameters.
Definition: gru.hpp:132
size_t & Rho()
Modify the maximum number of steps to backpropagate through time (BPTT).
Definition: gru.hpp:127
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: gru_impl.hpp:81
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: gru.hpp:135
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
OutputDataType & Gradient()
Modify the gradient.
Definition: gru.hpp:147
bool & Deterministic()
Modify the value of the deterministic parameter.
Definition: gru.hpp:122
GRU()
Create the GRU object.
Definition: gru_impl.hpp:27
The core includes that mlpack expects; standard C++ includes and Armadillo.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: gru_impl.hpp:382
bool Deterministic() const
The value of the deterministic parameter.
Definition: gru.hpp:120
OutputDataType const & Parameters() const
Get the parameters.
Definition: gru.hpp:130
size_t Rho() const
Get the maximum number of steps to backpropagate through time (BPTT).
Definition: gru.hpp:125
size_t InputShape() const
Get the shape of the input.
Definition: gru.hpp:159
OutputParameterVisitor exposes the output parameter of the given module.
Definition: output_parameter_visitor.hpp:27
std::vector< LayerTypes<> > & Model()
Get the model modules.
Definition: gru.hpp:150
An implementation of a gru network layer.
Definition: gru.hpp:58
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: gru.hpp:137
size_t OutSize() const
Get the number of output units.
Definition: gru.hpp:156
DeltaVisitor exposes the delta parameter of the given module.
Definition: delta_visitor.hpp:27
OutputDataType & Delta()
Modify the delta.
Definition: gru.hpp:142
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: gru_impl.hpp:196
OutputDataType const & Gradient() const
Get the gradient.
Definition: gru.hpp:145
size_t InSize() const
Get the number of input units.
Definition: gru.hpp:153
OutputDataType const & Delta() const
Get the delta.
Definition: gru.hpp:140