Skip to content

Instantly share code, notes, and snippets.

@spolu
Created September 23, 2014 00:24
Show Gist options
  • Save spolu/699025bd4773c2c2a171 to your computer and use it in GitHub Desktop.
Save spolu/699025bd4773c2c2a171 to your computer and use it in GitHub Desktop.
NN train
do {
err = 0;
for(unsigned int i = 0; i < train_in_.size(); i++) {
vector<double> res = this->learn(train_in_[i], train_out_[i]);
/* error calculation */
double e = 0;
for(unsigned int j = 0; j < res.size(); j++) {
e += pow(res[j] - train_out_[i][j], 2);
}
err += e / res.size();
}
err /= train_in_.size();
it++;
if(log_) {
cout << "[" << it << "] " << err << endl;
}
} while(err > error && it < iterations);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment