Exemplo n.º 1
0
        public async Task IntegrationSolvesXOrWithHyperbolicTangentActivationFunction()
        {
            var perceptron = await _errorBackPropagationTraining.TrainAsync(_trainingPatterns, errorMax : 0.1d, maxEpochs : 5000);

            foreach (var trainingPattern in _trainingPatterns)
            {
                var xorResult = await perceptron.FireAsync(trainingPattern.InputValues);

                xorResult.First().Should().BeApproximately(trainingPattern.IdealActivations.First(), 0.1d);
            }
        }
Exemplo n.º 2
0
        public async Task IntegrationSolvesXOrWithSoftmaxActivationFunction(bool oneHot)
        {
            _errorBackPropagationTraining = SetUpXOrTraining(bias: 0d, learningRate: 1d, momentum: 0.3d, slopeMultiplier: 1d, oneHot: oneHot);
            var perceptron = await _errorBackPropagationTraining.TrainAsync(_trainingPatterns, errorMax : 0.01d, maxEpochs : 1500);

            for (var t = 0; t < _trainingPatterns.Count; t++)
            {
                var trainingPattern = _trainingPatterns.ElementAt(t);
                var xorResult       = await perceptron.FireAsync(trainingPattern.InputValues);

                xorResult.ElementAt(0).Should().BeApproximately(trainingPattern.IdealActivations.ElementAt(0), 0.1d, "Pattern " + t);
                xorResult.ElementAt(1).Should().BeApproximately(trainingPattern.IdealActivations.ElementAt(1), 0.1d, "Pattern " + t);
            }
        }
        public async Task IntegrationSolvesXOrWithReluActivationFunction()
        {
            var timer = new Stopwatch();

            timer.Start();
            var perceptron = await _errorBackPropagationTraining.TrainAsync(_trainingPatterns, errorMax : 0.01d, maxEpochs : 10000);

            timer.Stop();
            Console.WriteLine(timer.ElapsedMilliseconds);
            for (var t = 0; t < _trainingPatterns.Count; t++)
            {
                var trainingPattern = _trainingPatterns.ElementAt(t);
                var xorResult       = await perceptron.FireAsync(trainingPattern.InputValues);

                xorResult.ElementAt(0).Should().BeApproximately(trainingPattern.IdealActivations.ElementAt(0), 0.1d, "Pattern " + t);
            }
        }