/** This trains the neural network according to the back propagation algorithm. The primary steps are: for each training pattern: feed forward propagate backward until the MSE becomes suitably small */ void CNeuralNet::train(std::vector<std::vector<double>> inputs, std::vector<std::vector<double>> outputs, uint trainingSetSize) { while (m_MSE > m_mse_cutoff) { for (int n = 0; n < trainingSetSize; ++n) { // Feed forward and update each nodes outputs feedForward(inputs[n]); // Propagate backwards propagateErrorBackward(outputs[n]); // Update the MSE m_MSE = meanSquaredError(outputs[n]); //cout << m_MSE << endl; // Once the cutoff value is met the network is considered trained if (m_MSE < m_mse_cutoff) { break; } } } //std::cout << "Training complete" << std::endl; }
virtual inline double computeDistance(const Shape * lhs, const Shape * rhs) const { return (meanSquaredError(lhs->x, rhs->x) + meanSquaredError(lhs->y, rhs->y)) / 2; }