12 #ifndef MLPACK_METHODS_ANN_RNN_HPP 13 #define MLPACK_METHODS_ANN_RNN_HPP 38 typename OutputLayerType = NegativeLogLikelihood<>,
39 typename InitializationRuleType = RandomInitialization,
40 typename... CustomLayers
47 InitializationRuleType,
66 const bool single =
false,
67 OutputLayerType outputLayer = OutputLayerType(),
68 InitializationRuleType initializeRule = InitializationRuleType());
96 template<
typename OptimizerType>
97 void Train(arma::cube predictors,
99 OptimizerType& optimizer);
124 template<
typename OptimizerType = mlpack::optimization::StandardSGD>
125 void Train(arma::cube predictors, arma::cube responses);
146 void Predict(arma::cube predictors,
148 const size_t batchSize = 256);
162 double Evaluate(
const arma::mat& parameters,
164 const size_t batchSize,
165 const bool deterministic);
180 const size_t batchSize)
182 return Evaluate(parameters, begin, batchSize,
true);
198 void Gradient(
const arma::mat& parameters,
201 const size_t batchSize);
214 template <
class LayerType,
class... Args>
215 void Add(Args... args) { network.push_back(
new LayerType(args...)); }
233 const size_t&
Rho()
const {
return rho; }
235 size_t&
Rho() {
return rho; }
238 const arma::cube&
Responses()
const {
return responses; }
260 template<
typename Archive>
261 void serialize(Archive& ar,
const unsigned int );
271 void Forward(arma::mat&& input);
288 template<
typename InputType>
295 void ResetDeterministic();
300 void ResetGradients(arma::mat& gradient);
306 OutputLayerType outputLayer;
310 InitializationRuleType initializeRule;
328 std::vector<
LayerTypes<CustomLayers...> > network;
331 arma::cube predictors;
334 arma::cube responses;
352 std::vector<arma::mat> moduleOutputParameter;
367 arma::mat currentGradient;
374 #include "rnn_impl.hpp" DeleteVisitor executes the destructor of the instantiated object.
RNN(const size_t rho, const bool single=false, OutputLayerType outputLayer=OutputLayerType(), InitializationRuleType initializeRule=InitializationRuleType())
Create the RNN object.
void ResetParameters()
Reset the module information (weights/parameters).
void Predict(arma::cube predictors, arma::cube &results, const size_t batchSize=256)
Predict the responses to a given set of predictors.
void serialize(Archive &ar, const unsigned int)
Serialize the model.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Reset()
Reset the state of the network.
size_t & Rho()
Modify the maximum length of backpropagation through time.
WeightSizeVisitor returns the number of weights of the given module.
const arma::mat & Parameters() const
Return the initial point for the optimization.
arma::mat & Parameters()
Modify the initial point for the optimization.
double Evaluate(const arma::mat ¶meters, const size_t begin, const size_t batchSize, const bool deterministic)
Evaluate the recurrent neural network with the given parameters.
Implementation of a standard recurrent neural network container.
void Train(arma::cube predictors, arma::cube responses, OptimizerType &optimizer)
Train the recurrent neural network on the given input data using the given optimizer.
double Evaluate(const arma::mat ¶meters, const size_t begin, const size_t batchSize)
Evaluate the recurrent neural network with the given parameters.
boost::variant< Add< arma::mat, arma::mat > *, AddMerge< arma::mat, arma::mat > *, BaseLayer< LogisticFunction, arma::mat, arma::mat > *, BaseLayer< IdentityFunction, arma::mat, arma::mat > *, BaseLayer< TanhFunction, arma::mat, arma::mat > *, BaseLayer< RectifierFunction, arma::mat, arma::mat > *, BatchNorm< arma::mat, arma::mat > *, BilinearInterpolation< arma::mat, arma::mat > *, Concat< arma::mat, arma::mat > *, ConcatPerformance< NegativeLogLikelihood< arma::mat, arma::mat >, arma::mat, arma::mat > *, Constant< arma::mat, arma::mat > *, Convolution< NaiveConvolution< ValidConvolution >, NaiveConvolution< FullConvolution >, NaiveConvolution< ValidConvolution >, arma::mat, arma::mat > *, DropConnect< arma::mat, arma::mat > *, Dropout< arma::mat, arma::mat > *, AlphaDropout< arma::mat, arma::mat > *, ELU< arma::mat, arma::mat > *, FlexibleReLU< arma::mat, arma::mat > *, Glimpse< arma::mat, arma::mat > *, HardTanH< arma::mat, arma::mat > *, Join< arma::mat, arma::mat > *, LeakyReLU< arma::mat, arma::mat > *, Linear< arma::mat, arma::mat > *, LinearNoBias< arma::mat, arma::mat > *, LogSoftMax< arma::mat, arma::mat > *, Lookup< arma::mat, arma::mat > *, LSTM< arma::mat, arma::mat > *, GRU< arma::mat, arma::mat > *, FastLSTM< arma::mat, arma::mat > *, MaxPooling< arma::mat, arma::mat > *, MeanPooling< arma::mat, arma::mat > *, MultiplyConstant< arma::mat, arma::mat > *, NegativeLogLikelihood< arma::mat, arma::mat > *, PReLU< arma::mat, arma::mat > *, Recurrent< arma::mat, arma::mat > *, RecurrentAttention< arma::mat, arma::mat > *, ReinforceNormal< arma::mat, arma::mat > *, Select< arma::mat, arma::mat > *, Sequential< arma::mat, arma::mat > *, VRClassReward< arma::mat, arma::mat > *, CustomLayers *... > LayerTypes
arma::cube & Predictors()
Modify the matrix of data points (predictors).
ResetVisitor executes the Reset() function.
OutputParameterVisitor exposes the output parameter of the given module.
const arma::cube & Predictors() const
Get the matrix of data points (predictors).
size_t NumFunctions() const
Return the number of separable functions (the number of predictor points).
void Gradient(const arma::mat ¶meters, const size_t begin, arma::mat &gradient, const size_t batchSize)
Evaluate the gradient of the recurrent neural network with the given parameters, and with respect to ...
DeltaVisitor exposes the delta parameter of the given module.
const size_t & Rho() const
Return the maximum length of backpropagation through time.
void Add(LayerTypes< CustomLayers... > layer)
arma::cube & Responses()
Modify the matrix of responses to the input data points.
~RNN()
Destructor to release allocated memory.
const arma::cube & Responses() const
Get the matrix of responses to the input data points.
void Shuffle()
Shuffle the order of function visitation.