Exemplo n.º 1
0
        public void SetUp()
        {
            _trainingPatterns = new List <TrainingPattern>
            {
                new TrainingPattern(new [] { -1d, -1d }, new [] { -1d }),
                new TrainingPattern(new [] { -1d, 1d }, new [] { 1d }),
                new TrainingPattern(new [] { 1d, -1d }, new [] { 1d }),
                new TrainingPattern(new [] { 1d, 1d }, new [] { -1d }),
            };

            _errorBackPropagationTraining = XOrSetUp.SetUpXOrTrainingSingleFold <HyperbolicTangentUnitActivationTraining>(bias: Math.E, learningRate: 0.1d);
        }
        public void SetUp()
        {
            _trainingPatterns = new List <TrainingPattern>
            {
                new TrainingPattern(new [] { 0d, 0d }, new [] { 0d }),
                new TrainingPattern(new [] { 1d, 0d }, new [] { 1d }),
                new TrainingPattern(new [] { 0d, 1d }, new [] { 1d }),
                new TrainingPattern(new [] { 1d, 1d }, new [] { 0d }),
            };

            _errorBackPropagationTraining = XOrSetUp.SetUpXOrTrainingSingleFold <SigmoidUnitActivationTraining>(bias: 0.5d, batch: true);
        }
        public void SetUp()
        {
            _trainingPatterns = new List <TrainingPattern>
            {
                new TrainingPattern(new [] { -1d, -1d }, new [] { -1d }),
                new TrainingPattern(new [] { -1d, 1d }, new [] { 1d }),
                new TrainingPattern(new [] { 1d, -1d }, new [] { 1d }),
                new TrainingPattern(new [] { 1d, 1d }, new [] { -1d }),
            };

            _errorBackPropagationTraining = XOrSetUp.SetUpXOrTrainingSingleFold <BipolarUnitActivationTraining>(bias: 1d);
        }
Exemplo n.º 4
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 void SetUp()
        {
            _trainingPatterns = new List <TrainingPattern>
            {
                new TrainingPattern(new [] { 0d, 0d }, new [] { 0d }),
                new TrainingPattern(new [] { 1d, 0d }, new [] { 1d }),
                new TrainingPattern(new [] { 0d, 1d }, new [] { 1d }),
                new TrainingPattern(new [] { 1d, 1d }, new [] { 0d }),
            };

            var inventoryAndChaining = new ErrorBackPropagationBuilder()
                                       .With.ANewLayerOfInputUnits(2)
                                       .ConnectedTo.ANewLayerOfHiddenUnits(3).With.UnitActivation <SigmoidUnitActivationTraining>()
                                       .ConnectedTo.ANewLayerOfOutputUnits(1).With.OutputUnitActivation <ReluUnitActivationTraining>();

            _errorBackPropagationTraining = XOrSetUp.SetUpXOrTraining(inventoryAndChaining, learningRate: 0.8d);
        }