3

How do I define unary functioon used in the artificial neural network C++ class

 3 weeks ago
source link: https://www.codeproject.com/Questions/5373295/How-do-I-define-unary-functioon-used-in-the-artifi
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What is the definition of the unary function in the following procedure?

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;
        }
    }
}



What I have tried:

I searched your source code for unary definition.
I searched the Eigen library for unary function definition.
I searched for unary function on the Web.
I defined my own arbitrary unary function to get the example to compile.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK