12 #ifndef MLPACK_METHODS_ANN_LAYER_LSTM_HPP 13 #define MLPACK_METHODS_ANN_LAYER_LSTM_HPP 55 typename InputDataType = arma::mat,
56 typename OutputDataType = arma::mat
71 LSTM(
const size_t inSize,
73 const size_t rho = std::numeric_limits<size_t>::max());
82 template<
typename InputType,
typename OutputType>
83 void Forward(InputType&& input, OutputType&& output);
94 template<
typename InputType,
typename OutputType>
97 OutputType&& cellState,
98 bool useCellState =
false);
109 template<
typename InputType,
typename ErrorType,
typename GradientType>
110 void Backward(
const InputType&& input,
134 template<
typename InputType,
typename ErrorType,
typename GradientType>
137 GradientType&& gradient);
140 size_t Rho()
const {
return rho; }
142 size_t&
Rho() {
return rho; }
155 OutputDataType
const&
Delta()
const {
return delta; }
157 OutputDataType&
Delta() {
return delta; }
160 OutputDataType
const&
Gradient()
const {
return grad; }
167 template<
typename Archive>
168 void serialize(Archive& ar,
const unsigned int );
190 OutputDataType weights;
193 OutputDataType prevOutput;
203 size_t gradientStepIdx;
206 OutputDataType cellActivationError;
209 OutputDataType delta;
215 OutputDataType outputParameter;
218 OutputDataType output2GateInputWeight;
221 OutputDataType input2GateInputWeight;
224 OutputDataType input2GateInputBias;
227 OutputDataType cell2GateInputWeight;
230 OutputDataType output2GateForgetWeight;
233 OutputDataType input2GateForgetWeight;
236 OutputDataType input2GateForgetBias;
239 OutputDataType cell2GateForgetWeight;
242 OutputDataType output2GateOutputWeight;
245 OutputDataType input2GateOutputWeight;
248 OutputDataType input2GateOutputBias;
251 OutputDataType cell2GateOutputWeight;
254 OutputDataType inputGate;
257 OutputDataType forgetGate;
260 OutputDataType hiddenLayer;
263 OutputDataType outputGate;
266 OutputDataType inputGateActivation;
269 OutputDataType forgetGateActivation;
272 OutputDataType outputGateActivation;
275 OutputDataType hiddenLayerActivation;
278 OutputDataType input2HiddenWeight;
281 OutputDataType input2HiddenBias;
284 OutputDataType output2HiddenWeight;
290 OutputDataType cellActivation;
293 OutputDataType forgetGateError;
296 OutputDataType outputGateError;
299 OutputDataType prevError;
302 OutputDataType outParameter;
305 OutputDataType inputCellError;
308 OutputDataType inputGateError;
311 OutputDataType hiddenError;
324 #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...
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.
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).