Пример #1
0
    public void RunMachineLearningTestCase()
    {
        double[] resultMLTestCase;

        if (testCaseOption == TestCaseOption.USE_IMAGES && (images == null || images.Count == 0))
        {
            Debug.LogError("Images not loaded");
        }

        if (totalWantedImagesToTest == 0)
        {
            imagesToTest = null;
        }

        TestCaseParameters param = MachineLearningTestCase.GetTestOption(testCaseOption, algoUsed);

        if (testCaseOption == TestCaseOption.USE_IMAGES)
        {
            param.neuronsPerLayer[0] = nbPixelInImage;
            param.neuronsPerLayer[param.neuronsPerLayer.Count - 1] = 1;
            param.X           = images;
            param.Y           = imageOutputs;
            param.sampleSize  = nbImagesLoaded;
            param.gamma       = (float)gamma;
            param.nbCentroids = nbCentroid;
        }

        if (algoUsed == AlgoUsed.RBF)
        {
            resultMLTestCase = RBFController.TrainRBFodel(this, param, imagesToTest, nbImagesToTestLoaded);
        }
        else
        {
            resultMLTestCase = MachineLearningTestCase.RunMachineLearningTestCase(algoUsed == AlgoUsed.LINEAR, param, epochs, learningRate, simulateTestCaseParameters, algoUsed, imagesToTest, nbImagesToTestLoaded);
        }

        if (testCaseOption != TestCaseOption.USE_IMAGES && testCaseOption != TestCaseOption.IMAGES_TEST)
        {
            DisplayOutput(resultMLTestCase);
        }
        else
        {
            foreach (var data in resultMLTestCase)
            {
                Debug.Log(data < 0.1 ? "Druid" : "Paladin");
            }
        }

        simulateTestCaseParameters = null;
    }
Пример #2
0
    public void GenerateWeights()
    {
        Debug.Log("Start Generate weights");
        if (images == null && images.Count > 0)
        {
            return;
        }

        //List<double> output = new List<double> {0, 1, 1, 1, 0};
        //TestCaseParameters test = MachineLearningTestCase.GetTestOption(TestCaseOption.ImagesTest);

        RBFController.StartGenerationRBFModel(this, images, nbPixelInImage, nbImagesLoaded, imageOutputs, 6, 2, 1000, 0.01f);
        //RBFController.TrainRBFodel(this, test.X, test.nplSize,test.sampleSize , test.Y, 2,2,100,0.1f);
    }