Guest User

Untitled

a guest
Oct 17th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1.     template<typename InputType, typename OutputType>
  2.     void Train(const InputType& trainingData,
  3.                const OutputType& trainingLabels,
  4.                const InputType& validationData,
  5.                const OutputType& validationLabels)
  6.     {
  7.       // This generates [0 1 2 3 ... (ElementCount(trainingData) - 1)]. The
  8.       // sequence will be used to iterate through the training data.
  9.       index = arma::linspace<arma::Col<size_t> >(0,
  10.           ElementCount(trainingData) - 1, ElementCount(trainingData));
  11.       epoch = 0;
  12.  
  13.       while(true)
  14.       {
  15.         if (shuffle)
  16.           index = arma::shuffle(index);
  17.  
  18.         Train(const_cast<InputType&>(trainingData),
  19.               const_cast<OutputType&>(trainingLabels));
  20.         Evaluate(const_cast<InputType&>(validationData),
  21.                  const_cast<OutputType&>(validationLabels));
  22.  
  23.         if (validationError <= tolerance)
  24.           break;
  25.  
  26.         if (maxEpochs > 0 && ++epoch >= maxEpochs)
  27.           break;
  28.       }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment