void train(NeuralNetwork& net) { cout << "Training:" << endl; RowVector input(3), output(3); int stop = 0; for (int i = 0; stop < 8 && i < 50000; i++) { cout << i + 1 << endl; for (int num = 0; stop < 8 && num < 8; num++) { input.coeffRef(0) = (num >> 2) & 1; input.coeffRef(1) = (num >> 1) & 1; input.coeffRef(2) = num & 1; output.coeffRef(0) = ((num + 1) >> 2) & 1; output.coeffRef(1) = ((num + 1) >> 1) & 1; output.coeffRef(2) = (num + 1) & 1; net.train(input, output); double mse = net.mse(); cout << "In [" << input << "] " << " Desired [" << output << "] " << " Out [" << net.mNeurons.back()->unaryExpr(ptr_fun(unary)) << "] " << " MSE [" << mse << "]" << endl; stop = mse < 0.1 ? stop + 1 : 0; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)