예제 #1
0
        public void AddDataAfterEducate(NeuralNetworkObj neuralNetworkObj, Dictionary <double[], double[]> prepareData)
        {
            data.Add("#########################################");
            data.Add("#########################################");

            int id = 1;

            foreach (var entity in prepareData)
            {
                double[] inputVector          = entity.Key;
                double[] expectedResultVector = entity.Value;

                neuralNetworkObj.Clear();
                neuralNetworkObj.SetInputVector(inputVector);
                neuralNetworkObj.Process();

                double[] resultVector = GetResultVector(neuralNetworkObj);

                data.Add($"ID: {id}");
                data.Add($"Epoch:  {neuralNetworkObj.GetCountEpochPassed()} (After educate)");
                data.Add($"Error:  {this.errorMethod.GetError(expectedResultVector, resultVector).ToString()}");
                data.Add("Expected Result:");
                foreach (var item in expectedResultVector)
                {
                    data.Add(item.ToString());
                }
                data.Add("Result:");
                foreach (var item in resultVector)
                {
                    data.Add(item.ToString());
                }
                data.Add("#########################################");
                id++;
            }
        }
예제 #2
0
        private double[] GetResultVector(NeuralNetworkObj neuralNetworkObj, double[] inputVector)
        {
            double[] result = new double[neuralNetworkObj.GetLastLayer().GetCountNeurons()];

            neuralNetworkObj.Clear();

            neuralNetworkObj.SetInputVector(inputVector);
            neuralNetworkObj.Process();

            List <NeuralNetwork.NeuronObj> neurons = neuralNetworkObj.GetLastLayer().GetListNeurons();

            for (int i = 0; i < neurons.Count; i++)
            {
                result[i] = neurons[i].GetOutputData();
            }

            return(result);
        }
        public int GetNumberFromImgVector(double[] inputVector)
        {
            if (inputVector.Length != this.countNeuronsInFirstLayer)
            {
                throw new Exception("Invalid input vector length.");
            }

            NeuralNetworkObj neuralNetworkObj = this.GetNeuralNetwork();

            neuralNetworkObj.Clear();
            neuralNetworkObj.SetInputVector(inputVector);
            neuralNetworkObj.Process();

            foreach (NeuronObj neuron in neuralNetworkObj.GetLastLayer().GetListNeurons())
            {
                if (neuron.GetOutputData() > MINIMUM_OUTPUT_DATA_FOR_SUCCESS_RESULT)
                {
                    return(neuron.Id);
                }
            }

            return(-1);
        }