Compute() public method

public Compute ( ) : double[]
return double[]
Beispiel #1
0
        private static void SelfTesting()
        {
            Console.WriteLine("Now Test the Network with some Inputs. The order of the inputs should be:");
            PrintNewLine();
            Console.WriteLine("inventory carrying cost , set-up cost , set-up time , production/ordering cost , demand for each period");
            PrintNewLine();

            while (true)
            {
                PrintUnderline(50);
                var values  = GetInputData($"Type {_numInputParameters} inputs: ");
                var results = _network.Compute(values);
                PrintNewLine();

                foreach (var result in results)
                {
                    Console.WriteLine($"Output: {result}");
                }

                PrintNewLine();

                var convertedResults = new double[results.Length];
                for (var i = 0; i < results.Length; i++)
                {
                    convertedResults[i] = results[i] > 0.5 ? 1 : 0;
                }

                var message = $"Was the result supposed to be {string.Join(" ", convertedResults)}? (yes/no/exit)";
                if (!GetBool(message))
                {
                    var offendingDataSet = _dataSets.FirstOrDefault(x => x.Values.SequenceEqual(values) && x.Targets.SequenceEqual(convertedResults));
                    _dataSets.Remove(offendingDataSet);

                    var expectedResults = GetExpectedResult("What were the expected results?");
                    if (!_dataSets.Exists(x => x.Values.SequenceEqual(values) && x.Targets.SequenceEqual(expectedResults)))
                    {
                        _dataSets.Add(new DataSet(values, expectedResults));
                    }

                    PrintNewLine();
                    Console.WriteLine("Retraining Network...");
                    PrintNewLine();

                    Train();
                }
                else
                {
                    PrintNewLine();
                    Console.WriteLine("Neat!");
                    Console.WriteLine("Encouraging Network...");
                    PrintNewLine();

                    Train();
                }
            }
        }
Beispiel #2
0
        private static void VerifyTraining()
        {
            Console.WriteLine("Let's test it!");
            PrintNewLine();

            while (true)
            {
                PrintUnderline(50);
                var values  = GetInputData(string.Format("Type {0} inputs: ", _numInputParameters));
                var results = _network.Compute(values);
                PrintNewLine();

                foreach (var result in results)
                {
                    Console.WriteLine("Output: {0}", result);
                }

                PrintNewLine();

                var convertedResults = new double[results.Length];
                for (var i = 0; i < results.Length; i++)
                {
                    convertedResults[i] = results[i] > 0.5 ? 1 : 0;
                }

                var message = string.Format("Was the result supposed to be {0}? (yes/no/exit)", String.Join(" ", convertedResults));
                if (!GetBool(message))
                {
                    var offendingDataSet = _dataSets.FirstOrDefault(x => x.Values.SequenceEqual(values) && x.Targets.SequenceEqual(convertedResults));
                    _dataSets.Remove(offendingDataSet);

                    var expectedResults = GetExpectedResult("What were the expected results?");
                    if (!_dataSets.Exists(x => x.Values.SequenceEqual(values) && x.Targets.SequenceEqual(expectedResults)))
                    {
                        _dataSets.Add(new DataSet(values, expectedResults));
                    }

                    PrintNewLine();
                    Console.WriteLine("Retraining Network...");
                    PrintNewLine();

                    Train();
                }
                else
                {
                    PrintNewLine();
                    Console.WriteLine("Neat!");
                    Console.WriteLine("Encouraging Network...");
                    PrintNewLine();

                    Train();
                }
            }
        }