12 #ifndef MLPACK_METHODS_ANN_LAYER_RECURRENT_HPP 13 #define MLPACK_METHODS_ANN_LAYER_RECURRENT_HPP 17 #include "../visitor/delete_visitor.hpp" 18 #include "../visitor/delta_visitor.hpp" 19 #include "../visitor/copy_visitor.hpp" 20 #include "../visitor/output_parameter_visitor.hpp" 21 #include "../visitor/input_shape_visitor.hpp" 40 typename InputDataType = arma::mat,
41 typename OutputDataType = arma::mat,
42 typename... CustomLayers
65 template<
typename StartModuleType,
66 typename InputModuleType,
67 typename FeedbackModuleType,
68 typename TransferModuleType>
70 const InputModuleType& input,
71 const FeedbackModuleType& feedback,
72 const TransferModuleType& transfer,
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>& error,
112 std::vector<LayerTypes<CustomLayers...> >&
Model() {
return network; }
120 OutputDataType
const&
Parameters()
const {
return parameters; }
130 OutputDataType
const&
Delta()
const {
return delta; }
132 OutputDataType&
Delta() {
return delta; }
135 OutputDataType
const&
Gradient()
const {
return gradient; }
140 size_t const&
Rho()
const {
return rho; }
148 template<
typename Archive>
149 void serialize(Archive& ar,
const uint32_t );
159 LayerTypes<CustomLayers...> startModule;
162 LayerTypes<CustomLayers...> inputModule;
165 LayerTypes<CustomLayers...> feedbackModule;
168 LayerTypes<CustomLayers...> transferModule;
190 OutputDataType parameters;
193 LayerTypes<CustomLayers...> initialModule;
196 LayerTypes<CustomLayers...> recurrentModule;
199 std::vector<LayerTypes<CustomLayers...> > network;
202 LayerTypes<CustomLayers...> mergeModule;
211 std::vector<arma::mat> feedbackOutputParameter;
214 OutputDataType delta;
217 OutputDataType gradient;
220 OutputDataType outputParameter;
223 arma::mat recurrentError;
bool Deterministic() const
The value of the deterministic parameter.
Definition: recurrent.hpp:115
DeleteVisitor executes the destructor of the instantiated object.
Definition: delete_visitor.hpp:27
OutputDataType const & Gradient() const
Get the gradient.
Definition: recurrent.hpp:135
size_t InputShape() const
Get the shape of the input.
Definition: recurrent_impl.hpp:132
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: recurrent.hpp:125
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
This visitor is to support copy constructor for neural network module.
Definition: copy_visitor.hpp:26
bool & Deterministic()
Modify the value of the deterministic parameter.
Definition: recurrent.hpp:117
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: recurrent_impl.hpp:227
OutputDataType & Gradient()
Modify the gradient.
Definition: recurrent.hpp:137
Recurrent()
Default constructor—this will create a Recurrent object that can't be used, so be careful! Make sure...
Definition: recurrent_impl.hpp:29
OutputParameterVisitor exposes the output parameter of the given module.
Definition: output_parameter_visitor.hpp:27
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: recurrent_impl.hpp:308
OutputDataType const & Delta() const
Get the delta.
Definition: recurrent.hpp:130
std::vector< LayerTypes< CustomLayers... > > & Model()
Get the model modules.
Definition: recurrent.hpp:112
OutputDataType const & Parameters() const
Get the parameters.
Definition: recurrent.hpp:120
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
size_t const & Rho() const
Get the number of steps to backpropagate through time.
Definition: recurrent.hpp:140
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: recurrent.hpp:127
DeltaVisitor exposes the delta parameter of the given module.
Definition: delta_visitor.hpp:27
OutputDataType & Delta()
Modify the delta.
Definition: recurrent.hpp:132
OutputDataType & Parameters()
Modify the parameters.
Definition: recurrent.hpp:122
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: recurrent_impl.hpp:182