public BackPropagationPerformanceComparisonContainer()
        {
            var neuralNetworkUnderTest =
                NeuralNetwork
                .For(NeuralNetworkContext.MaximumPrecision)
                .WithInputLayer(neuronCount: 5, activationType: ActivationType.Sigmoid)
                .WithHiddenLayer(neuronCount: 100, activationType: ActivationType.Sigmoid)
                .WithHiddenLayer(neuronCount: 70, activationType: ActivationType.TanH)
                .WithHiddenLayer(neuronCount: 40, activationType: ActivationType.TanH)
                .WithHiddenLayer(neuronCount: 100, activationType: ActivationType.Sigmoid)
                .WithOutputLayer(neuronCount: 2, activationType: ActivationType.Sigmoid)
                .Build();

            trainingData = new[] {
                TrainingDataSet.For(new [] { 0.78, 0.99, 0.67, 0.72, 0.22 }, new [] { 0.12, 0.14 })
            };

            multiThreadedController = TrainingController.For(
                BackPropagation
                .WithConfiguration(neuralNetworkUnderTest, ParallelOptionsExtensions.UnrestrictedMultiThreadedOptions));

            singleThreadedController = TrainingController.For(
                BackPropagation
                .WithConfiguration(neuralNetworkUnderTest, ParallelOptionsExtensions.SingleThreadedOptions));
        }
        public async Task TrainConfiguredNetworkForEpochs(
            int epochs,
            NeuralNetworkTrainingConfiguration trainingConfig)
        {
            var trainingData = dataProvider.TrainingData
                               .Select(transaction => transaction.ToTrainingData())
                               .ToList();

            await TrainingController.For(BackPropagation.WithConfiguration(
                                             networkAccessor.TargetNetwork,
                                             ParallelOptionsExtensions.MultiThreadedOptions(trainingConfig.ThreadCount),
                                             trainingConfig.LearningRate,
                                             trainingConfig.Momentum))
            .TrainForEpochsOrErrorThresholdMet(trainingData, epochs, trainingConfig.MinimumErrorThreshold);
        }
Exemplo n.º 3
0
        public async void CanSuccessfullySolveXorProblemTrainingForErrorThreshold()
        {
            var neuralNetwork = NeuralNetwork.For(NeuralNetworkContext.MaximumPrecision)
                                .WithInputLayer(neuronCount: 2, activationType: ActivationType.Sigmoid)
                                .WithHiddenLayer(neuronCount: 2, activationType: ActivationType.TanH)
                                .WithOutputLayer(neuronCount: 1, activationType: ActivationType.Sigmoid)
                                .Build();

            await TrainingController
            .For(BackPropagation.WithConfiguration(
                     neuralNetwork,
                     ParallelOptionsExtensions.UnrestrictedMultiThreadedOptions,
                     learningRate: 0.4,
                     momentum: 0.9))
            .TrainForErrorThreshold(XorTrainingData(), minimumErrorThreshold: 0.01);

            AssertPredictionsForTrainedNeuralNetwork(neuralNetwork);
        }
        public async void CanSuccessfullySolveIrisProblemTrainingForEpochs()
        {
            var neuralNetwork = NeuralNetwork.For(NeuralNetworkContext.MaximumPrecision)
                                .WithInputLayer(neuronCount: 4, activationType: ActivationType.Sigmoid)
                                .WithHiddenLayer(neuronCount: 8, activationType: ActivationType.Sigmoid)
                                .WithHiddenLayer(neuronCount: 5, activationType: ActivationType.Sigmoid)
                                .WithOutputLayer(neuronCount: 3, activationType: ActivationType.TanH)
                                .Build();

            await TrainingController
            .For(BackPropagation.WithConfiguration(
                     neuralNetwork,
                     ParallelOptionsExtensions.UnrestrictedMultiThreadedOptions,
                     learningRate: 1.15,
                     momentum: 0.4))
            .TrainForEpochs(IrisDataSet.TrainingData, maximumEpochs: 1000);

            AssertPredictionsForTrainedNeuralNetwork(neuralNetwork);
        }
Exemplo n.º 5
0
        private async void button3_Click(object sender, EventArgs e)
        {
            progressBar1.Value = 20;
            neuralNetwork      = NeuralNetwork.For(NeuralNetworkContext.MaximumPrecision)
                                 .WithInputLayer(neuronCount: 64, activationType: ActivationType.Sigmoid)
                                 .WithHiddenLayer(neuronCount: 10, activationType: ActivationType.Sigmoid)
                                 .WithOutputLayer(neuronCount: 3, activationType: ActivationType.Sigmoid)
                                 .Build();
            progressBar1.Value = 40;
            await TrainingController
            .For(BackPropagation.WithConfiguration(
                     neuralNetwork,
                     ParallelOptionsExtensions.UnrestrictedMultiThreadedOptions,
                     learningRate: 1.8,
                     momentum: 0.9))
            .TrainForEpochsOrErrorThresholdMet(GetMyTrainingData(), maximumEpochs: 5000, errorThreshold: 0.05);

            progressBar1.Value   = 100;
            button4.Visible      = true;
            progressBar1.Visible = false;
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            ConfigureLogging();

            var neuralNetwork = NeuralNetwork.For(NeuralNetworkContext.MaximumPrecision)
                                .WithInputLayer(neuronCount: 2, activationType: ActivationType.Sigmoid)
                                .WithHiddenLayer(neuronCount: 5, activationType: ActivationType.TanH)
                                .WithOutputLayer(neuronCount: 1, activationType: ActivationType.Sigmoid)
                                .Build();

            TrainingController
            .For(BackPropagation.WithConfiguration(
                     neuralNetwork,
                     ParallelOptionsExtensions.UnrestrictedMultiThreadedOptions,
                     learningRate: 0.6,
                     momentum: 0.9))
            .TrainForEpochsOrErrorThresholdMet(GetXorTrainingData(), maximumEpochs: 5000, errorThreshold: 0.001)
            .GetAwaiter()
            .GetResult();

            MakeExamplePredictions(neuralNetwork);
        }