Esempio n. 1
0
        public static void Compute <T>(BasicNetwork network, ILearningScenario <T> scenario,
                                       IList <T> dataSource)
        {
            var computingSet = scenario.GetSet(dataSource);

            foreach (var item in computingSet)
            {
                var output = network.Compute(item.Input);
                Console.WriteLine($"Input: {item.Input[0]}, {item.Input[1]} Ideal: {item.Ideal[0]} Actual: {output[0]}");
            }
        }
Esempio n. 2
0
        public static BasicNetwork Train <T>(ILearningScenario <T> scenario,
                                             IList <T> dataSource,
                                             BasicNetwork network = null)
        {
            if (network == null)
            {
                network = NeuralNetwork
                          .CreateNetwork(scenario.InputParams.Count,
                                         scenario.OutputParams.Count);
            }

            BasicMLDataSet trainingSet = scenario.GetSet(dataSource);
            var            training    = GetTraining(network, trainingSet);

            int epoch = 1;

            do
            {
                training.Iteration();
                Debug.WriteLine($"Iteration No: {epoch++}, Error: {training.Error}");
            }while (training.Error > scenario.MaxError || epoch < scenario.MaxIterations);
            return(network);
        }