13#ifndef MLPACK_METHODS_ANN_LAYER_FAST_LSTM_HPP
14#define MLPACK_METHODS_ANN_LAYER_FAST_LSTM_HPP
63 typename InputDataType = arma::mat,
64 typename OutputDataType = arma::mat
71 typedef typename OutputDataType::elem_type
ElemType;
85 const size_t rho = std::numeric_limits<size_t>::max());
94 template<
typename InputType,
typename OutputType>
95 void Forward(
const InputType& input, OutputType& output);
106 template<
typename InputType,
typename ErrorType,
typename GradientType>
131 template<
typename InputType,
typename ErrorType,
typename GradientType>
133 const ErrorType& error,
134 GradientType& gradient);
137 size_t Rho()
const {
return rho; }
139 size_t&
Rho() {
return rho; }
152 OutputDataType
const&
Delta()
const {
return delta; }
154 OutputDataType&
Delta() {
return delta; }
157 OutputDataType
const&
Gradient()
const {
return grad; }
170 template<
typename Archive>
180 template<
typename InputType,
typename OutputType>
181 void FastSigmoid(
const InputType& input, OutputType& sigmoids)
183 for (
size_t i = 0; i < input.n_elem; ++i)
184 sigmoids(i) = FastSigmoid(input(i));
200 z = (1.5 * x / (1 + x));
202 z = (0.935409070603099 + 0.0458812946797165 * (x - 1.7));
204 z = 0.99505475368673;
210 z = -(1.5 * xx / (1 + xx));
212 z = -(0.935409070603099 + 0.0458812946797165 * (xx - 1.7));
214 z = -0.99505475368673;
217 return 0.5 * (z + 1.0);
239 OutputDataType weights;
242 OutputDataType prevOutput;
252 size_t gradientStepIdx;
255 OutputDataType cellActivationError;
258 OutputDataType delta;
264 OutputDataType outputParameter;
267 OutputDataType output2GateWeight;
270 OutputDataType input2GateWeight;
273 OutputDataType input2GateBias;
279 OutputDataType gateActivation;
282 OutputDataType stateActivation;
288 OutputDataType cellActivation;
291 OutputDataType forgetGateError;
294 OutputDataType prevError;
297 OutputDataType outParameter;
310#include "fast_lstm_impl.hpp"
An implementation of a faster version of the Fast LSTM network layer.
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.
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.
OutputDataType::elem_type ElemType
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)
FastLSTM(const size_t inSize, const size_t outSize, const size_t rho=std::numeric_limits< size_t >::max())
Create the Fast LSTM layer object using the specified parameters.
FastLSTM()
Create the Fast LSTM object.
OutputDataType & Gradient()
Modify the gradient.
OutputDataType & OutputParameter()
Modify the output parameter.
size_t InSize() const
Get the number of input units.
InputDataType::elem_type InputElemType
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.