12 #ifndef MLPACK_METHODS_ANN_LAYER_LSTM_HPP 13 #define MLPACK_METHODS_ANN_LAYER_LSTM_HPP 60 typename InputDataType = arma::mat,
61 typename OutputDataType = arma::mat
76 LSTM(
const size_t inSize,
78 const size_t rho = std::numeric_limits<size_t>::max());
87 template<
typename InputType,
typename OutputType>
88 void Forward(InputType&& input, OutputType&& output);
99 template<
typename InputType,
typename ErrorType,
typename GradientType>
100 void Backward(
const InputType&& input,
124 template<
typename InputType,
typename ErrorType,
typename GradientType>
127 GradientType&& gradient);
130 size_t Rho()
const {
return rho; }
132 size_t&
Rho() {
return rho; }
150 OutputDataType
const&
Delta()
const {
return delta; }
152 OutputDataType&
Delta() {
return delta; }
155 OutputDataType
const&
Gradient()
const {
return grad; }
162 template<
typename Archive>
163 void serialize(Archive& ar,
const unsigned int );
185 OutputDataType weights;
188 OutputDataType prevOutput;
198 size_t gradientStepIdx;
201 OutputDataType cellActivationError;
204 OutputDataType delta;
210 InputDataType inputParameter;
213 OutputDataType outputParameter;
216 OutputDataType output2GateInputWeight;
219 OutputDataType input2GateInputWeight;
222 OutputDataType input2GateInputBias;
225 OutputDataType cell2GateInputWeight;
228 OutputDataType output2GateForgetWeight;
231 OutputDataType input2GateForgetWeight;
234 OutputDataType input2GateForgetBias;
237 OutputDataType cell2GateForgetWeight;
240 OutputDataType output2GateOutputWeight;
243 OutputDataType input2GateOutputWeight;
246 OutputDataType input2GateOutputBias;
249 OutputDataType cell2GateOutputWeight;
252 OutputDataType inputGate;
255 OutputDataType forgetGate;
258 OutputDataType hiddenLayer;
261 OutputDataType outputGate;
264 OutputDataType inputGateActivation;
267 OutputDataType forgetGateActivation;
270 OutputDataType outputGateActivation;
273 OutputDataType hiddenLayerActivation;
276 OutputDataType input2HiddenWeight;
279 OutputDataType input2HiddenBias;
282 OutputDataType output2HiddenWeight;
288 OutputDataType cellActivation;
291 OutputDataType forgetGateError;
294 OutputDataType outputGateError;
297 OutputDataType prevError;
300 OutputDataType outParameter;
303 OutputDataType inputCellError;
306 OutputDataType inputGateError;
309 OutputDataType hiddenError;
322 #include "lstm_impl.hpp" OutputDataType const & OutputParameter() const
Get the output parameter.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & Gradient()
Modify the gradient.
OutputDataType & OutputParameter()
Modify the output parameter.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
size_t Rho() const
Get the maximum number of steps to backpropagate through time (BPTT).
OutputDataType const & Parameters() const
Get the parameters.
void Forward(InputType &&input, OutputType &&output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
InputDataType & InputParameter()
Modify the input parameter.
OutputDataType const & Delta() const
Get the delta.
void Backward(const InputType &&input, ErrorType &&gy, GradientType &&g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
LSTM()
Create the LSTM object.
InputDataType const & InputParameter() const
Get the input parameter.
OutputDataType const & Gradient() const
Get the gradient.
void ResetCell(const size_t size)
OutputDataType & Delta()
Modify the delta.
OutputDataType & Parameters()
Modify the parameters.
size_t & Rho()
Modify the maximum number of steps to backpropagate through time (BPTT).