13 #ifndef MLPACK_METHODS_ANN_LAYER_FAST_LSTM_HPP
14 #define MLPACK_METHODS_ANN_LAYER_FAST_LSTM_HPP
62 typename InputDataType = arma::mat,
63 typename OutputDataType = arma::mat
70 typedef typename OutputDataType::elem_type
ElemType;
84 const size_t rho = std::numeric_limits<size_t>::max());
93 template<
typename InputType,
typename OutputType>
94 void Forward(InputType&& input, OutputType&& output);
105 template<
typename InputType,
typename ErrorType,
typename GradientType>
106 void Backward(
const InputType&& input,
130 template<
typename InputType,
typename ErrorType,
typename GradientType>
133 GradientType&& gradient);
136 size_t Rho()
const {
return rho; }
138 size_t&
Rho() {
return rho; }
151 OutputDataType
const&
Delta()
const {
return delta; }
153 OutputDataType&
Delta() {
return delta; }
156 OutputDataType
const&
Gradient()
const {
return grad; }
163 template<
typename Archive>
164 void serialize(Archive& ar,
const unsigned int );
173 template<
typename InputType,
typename OutputType>
174 void FastSigmoid(InputType&& input, OutputType&& sigmoids)
176 for (
size_t i = 0; i < input.n_elem; ++i)
177 sigmoids(i) = FastSigmoid(input(i));
193 z = (1.5 * x / (1 + x));
195 z = (0.935409070603099 + 0.0458812946797165 * (x - 1.7));
197 z = 0.99505475368673;
203 z = -(1.5 * xx / (1 + xx));
205 z = -(0.935409070603099 + 0.0458812946797165 * (xx - 1.7));
207 z = -0.99505475368673;
210 return 0.5 * (
z + 1.0);
232 OutputDataType weights;
235 OutputDataType prevOutput;
245 size_t gradientStepIdx;
248 OutputDataType cellActivationError;
251 OutputDataType delta;
257 OutputDataType outputParameter;
260 OutputDataType output2GateWeight;
263 OutputDataType input2GateWeight;
266 OutputDataType input2GateBias;
272 OutputDataType gateActivation;
275 OutputDataType stateActivation;
281 OutputDataType cellActivation;
284 OutputDataType forgetGateError;
287 OutputDataType prevError;
290 OutputDataType outParameter;
303 #include "fast_lstm_impl.hpp"