Example #1
0
    void Train()
    {
        // build input and output
        List <Matrix <double> > xs  = new List <Matrix <double> >();
        List <Matrix <double> > y_s = new List <Matrix <double> >();

        for (LinkedListNode <Vector3> i = inputs.First; i != inputs.Last.Next; i = i.Next)
        {
            Matrix <double> x = Matrix <double> .Build.Dense(1, inputDim);

            x[0, 0] = i.Value.x;
            x[0, 1] = i.Value.y;
            x[0, 2] = i.Value.z;
            xs.Add(x);
        }

        for (LinkedListNode <Vector2> i = targets.First; i != targets.Last.Next; i = i.Next)
        {
            Matrix <double> y_ = Matrix <double> .Build.Dense(1, outputDim);

            y_[0, 0] = i.Value.x * 0.5 + 0.5;
            y_[0, 1] = i.Value.y * 0.5 + 0.5;
            y_s.Add(y_);
        }

        // train
        loss = rnn.Train(xs, y_s, 1e-2);
    }