public void Test() { int successTime = 0; double mse = 0; for (int i = 0; i < _testSetSize; i++) { double labelData = _dataMgr.GetDoubleLabelData(i); double [] inputData = _dataMgr.GetNormalizedInputData(i); double[] labelData2 = _dataMgr.GetIntLabelData(i); _mlp.SetInput(inputData); _mlp.Feedfowrad(); double maxIndex = _mlp.GetMaxOutputIndex(); if (labelData == maxIndex) { successTime++; } double[] outputData = _mlp.GetIntOutput(); mse += GetMSE(outputData, labelData2); } _mse = mse / (double)_testSetSize; _successRate = (double)successTime / (double)_testSetSize; Console.WriteLine("Test set - success rate : " + _successRate + " - mse : " + _mse); }
void Test() { int successTime = 0; double mse = 0; if (!_randomSelect) { Random rnd = new Random(); int testStartIndex = rnd.Next(_dataMgr.count - _testSetSize); for (int i = testStartIndex; i < testStartIndex + _testSetSize; i++) { if (!_normalizeOuput) { double labelData = _dataMgr.GetDoubleLabelData(i); double[] labelData2 = _dataMgr.GetIntLabelData(i); double[] inputData; if (_normalizeInput) { inputData = _dataMgr.GetNormalizedInputData(i); } else { inputData = _dataMgr.GetInputData(i); } _network.SetInput(inputData); _network.Feedfowrad(); double maxIndex = _network.GetMaxOutputIndex(); //Console.Write(maxIndex); //Console.Write("/"+labelData + " "); //Console.Write("compare " + labelData + " and " + maxIndex + " "); if (labelData == maxIndex) { successTime++; } double [] outputData = _network.GetOutput(); mse += GetMSE(outputData, labelData2); } } } //Console.Write("\n"); _mse = mse / (double)_testSetSize; _successRate = (double)successTime / (double)_testSetSize; }
public void OnlineTrain() { int trainCnt = 0; Random rnd = new Random(); while (!stopCriteria()) { Console.Write("\n"); for (int i = 0; i < _trainSetSize; i++) { int index = rnd.Next(_dataMgr.count - 1); //Console.WriteLine(i); Console.Write("-"); double[] input; if (_normalizeInput) { input = _dataMgr.GetNormalizedInputData(index); } else { input = _dataMgr.GetInputData(index); } double [] label = new double[] { _dataMgr.GetDoubleLabelData(index) / 10 }; _network.OnlineTrain(input, label); } Console.Write("\n"); Test(); trainCnt++; Console.WriteLine("TRAINING TIME " + trainCnt + " with successrate " + _successRate + " and mse " + _mse); } }