Пример #1
0
        private async Task Validate()
        {
            //Console.WriteLine("Validating...");
            bool shouldSave = false;

            WeightStore ws = new WeightStore()
            {
                Statistics = new double[32], WeightsHL0 = nnld[0].Weights, WeightsHL1 = nnld[1].Weights, WeightsHL2 = nnld[2].Weights, WeightsOL = nnld[3].Weights
            };

            for (int i = 0; i < valdataSet.Count; i++)
            {
                double[] hiddenLayer1 = await neuralNetwork.PerceptronLayer(nnld[0].NumberOfNetworks, valdataSet[i].PublicAddressDouble, nnld[0].Weights, nnld[0].NumberOfInputs, nnld[0].Biases);

                double[] hiddenLayer2 = await neuralNetwork.PerceptronLayer(nnld[1].NumberOfNetworks, hiddenLayer1, nnld[1].Weights, nnld[1].NumberOfInputs, nnld[1].Biases);

                double[] hiddenLayer3 = await neuralNetwork.PerceptronLayer(nnld[2].NumberOfNetworks, hiddenLayer2, nnld[2].Weights, nnld[2].NumberOfInputs, nnld[2].Biases);

                double[] outputlayer = await neuralNetwork.PerceptronLayer(nnld[3].NumberOfNetworks, hiddenLayer3, nnld[3].Weights, nnld[3].NumberOfInputs, nnld[3].Biases);

                outputlayer = await activationFunctions.ByteOutput(outputlayer, 29180215);

                ws = await ValidateTest(outputlayer, i, ws);
            }

            for (int i = 0; i < ws.Statistics.Length; i++)
            {
                if (ws.Statistics[i] > 50)  //Means 0.005 based upon validation set of 10000.  Adjust as required.  Use to determine what gets saved
                {
                    shouldSave = true;

                    if (ws.Statistics[i] > maxStat)
                    {
                        maxStat = ws.Statistics[i];
                        Console.WriteLine(string.Format("Current highest stat is: {0}, Probability: {1}", maxStat, maxStat / 10000));
                    }
                }
            }

            if (shouldSave)
            {
                //Console.WriteLine(Environment.NewLine);
                //SerialiseWeightsAndSaveToDB(ws.Statistics);  //Save to DB using entity framework - uncomment to enable - remember to set connection string in WeightsDBContext
            }
        }
Пример #2
0
        private async Task <WeightStore> ValidateTest(double[] outputlayer, int index, WeightStore ws)
        {
            outputlayer = await ConvertFromBinaryToDouble(outputlayer);

            for (int i = 0; i < valdataSet[index].PrivateKey.Length; i++)
            {
                if (valdataSet[index].PrivateKey[i] == (int)outputlayer[i])  //Check output against private keys
                {
                    ws.Statistics[i]++;
                }
            }

            return(ws);
        }