Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename InputType, typename OutputType>
- void Train(const InputType& trainingData,
- const OutputType& trainingLabels,
- const InputType& validationData,
- const OutputType& validationLabels)
- {
- // This generates [0 1 2 3 ... (ElementCount(trainingData) - 1)]. The
- // sequence will be used to iterate through the training data.
- index = arma::linspace<arma::Col<size_t> >(0,
- ElementCount(trainingData) - 1, ElementCount(trainingData));
- epoch = 0;
- while(true)
- {
- if (shuffle)
- index = arma::shuffle(index);
- Train(const_cast<InputType&>(trainingData),
- const_cast<OutputType&>(trainingLabels));
- Evaluate(const_cast<InputType&>(validationData),
- const_cast<OutputType&>(validationLabels));
- if (validationError <= tolerance)
- break;
- if (maxEpochs > 0 && ++epoch >= maxEpochs)
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment