Example #1
0
    LinearTraining createTrainingConfiguration()
    {
        LinearTraining c = new LinearTraining();

        c.NbElements = targetTransforms.Length;
        c.NbInputs   = 2;

        c.TrainingExemples = new double[c.NbElements * c.NbInputs];
        c.ExpectedResults  = new int[c.NbElements];

        for (int i = 0; i < targetMeshRenderers.Length; ++i)
        {
            MeshRenderer mr = targetMeshRenderers[i].GetComponent <MeshRenderer>();
            if (mr.material.color == redMat.color)
            {
                Transform t = targetTransforms[i].GetComponent <Transform>();
                c.TrainingExemples[i * c.NbInputs]     = t.position.x;
                c.TrainingExemples[i * c.NbInputs + 1] = t.position.z;
                c.ExpectedResults[i] = -1;
            }
            if (mr.material.color == blueMat.color)
            {
                Transform t = targetTransforms[i].GetComponent <Transform>();
                c.TrainingExemples[i * c.NbInputs]     = t.position.x;
                c.TrainingExemples[i * c.NbInputs + 1] = t.position.z;
                c.ExpectedResults[i] = 1;
            }
        }

        c.MaxIteration = 10000;

        return(c);
    }
Example #2
0
    void linearScenario(LinearTraining c, System.IntPtr model)
    {
        //printModel(model);

        trainPLA(c.TrainingExemples, c.NbInputs, c.NbElements, c.ExpectedResults, model, c.MaxIteration);

        //printModel(model);

        adjustPlan(model, c.NbInputs);

        removeModel(model);
    }