12#ifndef MLPACK_METHODS_ANN_LAYER_LSTM_HPP
13#define MLPACK_METHODS_ANN_LAYER_LSTM_HPP
59 typename InputDataType = arma::mat,
60 typename OutputDataType = arma::mat
77 const size_t rho = std::numeric_limits<size_t>::max());
86 template<
typename InputType,
typename OutputType>
87 void Forward(
const InputType& input, OutputType& output);
98 template<
typename InputType,
typename OutputType>
101 OutputType& cellState,
102 bool useCellState =
false);
113 template<
typename InputType,
typename ErrorType,
typename GradientType>
138 template<
typename InputType,
typename ErrorType,
typename GradientType>
140 const ErrorType& error,
141 GradientType& gradient);
144 size_t Rho()
const {
return rho; }
146 size_t&
Rho() {
return rho; }
159 OutputDataType
const&
Delta()
const {
return delta; }
161 OutputDataType&
Delta() {
return delta; }
164 OutputDataType
const&
Gradient()
const {
return grad; }
177 template<
typename Archive>
200 OutputDataType weights;
203 OutputDataType prevOutput;
213 size_t gradientStepIdx;
216 OutputDataType cellActivationError;
219 OutputDataType delta;
225 OutputDataType outputParameter;
228 OutputDataType output2GateInputWeight;
231 OutputDataType input2GateInputWeight;
234 OutputDataType input2GateInputBias;
237 OutputDataType cell2GateInputWeight;
240 OutputDataType output2GateForgetWeight;
243 OutputDataType input2GateForgetWeight;
246 OutputDataType input2GateForgetBias;
249 OutputDataType cell2GateForgetWeight;
252 OutputDataType output2GateOutputWeight;
255 OutputDataType input2GateOutputWeight;
258 OutputDataType input2GateOutputBias;
261 OutputDataType cell2GateOutputWeight;
264 OutputDataType inputGate;
267 OutputDataType forgetGate;
270 OutputDataType hiddenLayer;
273 OutputDataType outputGate;
276 OutputDataType inputGateActivation;
279 OutputDataType forgetGateActivation;
282 OutputDataType outputGateActivation;
285 OutputDataType hiddenLayerActivation;
288 OutputDataType input2HiddenWeight;
291 OutputDataType input2HiddenBias;
294 OutputDataType output2HiddenWeight;
300 OutputDataType cellActivation;
303 OutputDataType forgetGateError;
306 OutputDataType outputGateError;
309 OutputDataType prevError;
312 OutputDataType outParameter;
315 OutputDataType inputCellError;
318 OutputDataType inputGateError;
321 OutputDataType hiddenError;
334#include "lstm_impl.hpp"
Implementation of the LSTM module class.
void Forward(const InputType &input, OutputType &output)
Ordinary feed-forward pass of a neural network, evaluating the function f(x) by propagating the activ...
OutputDataType const & Delta() const
Get the delta.
size_t & Rho()
Modify the maximum number of steps to backpropagate through time (BPTT).
OutputDataType const & Parameters() const
Get the parameters.
size_t OutSize() const
Get the number of output units.
LSTM()
Create the LSTM object.
void Gradient(const InputType &input, const ErrorType &error, GradientType &gradient)
size_t Rho() const
Get the maximum number of steps to backpropagate through time (BPTT).
OutputDataType const & OutputParameter() const
Get the output parameter.
LSTM(const size_t inSize, const size_t outSize, const size_t rho=std::numeric_limits< size_t >::max())
Create the LSTM layer object using the specified parameters.
void Backward(const InputType &input, const ErrorType &gy, GradientType &g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
OutputDataType const & Gradient() const
Get the gradient.
void ResetCell(const size_t size)
OutputDataType & Gradient()
Modify the gradient.
OutputDataType & OutputParameter()
Modify the output parameter.
size_t InSize() const
Get the number of input units.
void Forward(const InputType &input, OutputType &output, OutputType &cellState, bool useCellState=false)
Ordinary feed-forward pass of a neural network, evaluating the function f(x) by propagating the activ...
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Parameters()
Modify the parameters.
OutputDataType & Delta()
Modify the delta.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.