void Start() { /*Application.runInBackground = true; * if (ErrorCheck() == false) { * testCounter = 0; * finished = new Semaphore(1, 1); * nets = new Net[populationSize]; * finishedNetID = new float[populationSize,2]; * * GenerateInitialNets(); * GeneratePopulation(); * }*/ //float[][] XOR_QUESTION = { new float[]{0, 0}, new float[] { 0, 1}, new float[] { 1, 0}, new float[] { 1, 1} }; //float[][] XOR_ANSWER = { new float[] { 0f }, new float[] { 1f }, new float[] { 1f }, new float[] { 0f } }; float[][] XOR_QUESTION = { new float[] { 0, 0, 0 }, new float[] { 0, 0, 1 }, new float[] { 0, 1, 0 }, new float[] { 0, 1, 1 }, new float[] { 1, 0, 0 }, new float[] { 1, 0, 1 }, new float[] { 1, 1, 0 }, new float[] { 1, 1, 1 } }; float[][] XOR_ANSWER = { new float[] { 0f }, new float[] { 1f }, new float[] { 1f }, new float[] { 0f }, new float[] { 1f }, new float[] { 0f }, new float[] { 0f }, new float[] { 1f } }; Net net = new Net(0, numberOfInputPerceptrons, numberOfOutputPerceptrons, numberOfHiddenLayers, numberOfHiddenPerceptrons, 0f); net.SetRandomWeights(); for (int i = 0; i < 100000; i++) { int randomIndex = UnityEngine.Random.Range(0, 8); float[] input = XOR_QUESTION[randomIndex]; float[] answer = XOR_ANSWER[randomIndex]; float[] output = net.FireNet(input); net.BackwardPassNet(output, XOR_ANSWER[randomIndex]); net.UpdateBackwardPass(); //Debug.Log("Input: " + input[0] + " " + input[1] + " " + answer[0] + " " + output[0]); } Debug.Log("@@@@@Test@@@@@@"); for (int i = 0; i < 8; i++) { float[] input = XOR_QUESTION[i]; float[] answer = XOR_ANSWER[i]; float[] output = net.FireNet(input); Debug.Log("Input: " + input[0] + " " + input[1] + " " + input[2] + " Answer: " + answer[0] + " Out: " + output[0] + " Err: " + Mathf.Abs(answer[0] - output[0])); } }