Exemplo n.º 1
0
        public void When_Forward_Pass_Invoked_Then_Output_Is_Calculated_Correctly()
        {
            var testObject = NeuralNetTestSetup.GetConfiguredNet();

            var output = testObject.ForwardPass(new[] { 0.05, 0.10 });

            output.Should().Equal(new[] { 0.75136507, 0.772928465 }, AreEqualApproximately);
        }
Exemplo n.º 2
0
        public void When_Total_Error_Calculated_Then_It_Is_Correct()
        {
            var testObject  = NeuralNetTestSetup.GetConfiguredNet();
            var trainingSet = new TrainingSet(new[] { new TrainingSample(new[] { 0.05, 0.10 }, new[] { 0.01, 0.99 }) });

            var totalError = ErrorFunctions.TotalError(testObject, trainingSet);

            totalError.Should().BeApproximately(0.298371109, Precision);
        }
        //[InlineData(10000, 0.0000351085)]
        public void When_Then(int iterationsCount, double expectedError)
        {
            var net         = NeuralNetTestSetup.GetConfiguredNet();
            var trainingSet = new TrainingSet(new[] { new TrainingSample(new[] { 0.05, 0.10 }, new[] { 0.01, 0.99 }) });

            _trainingCfg = new TrainingConfiguration {
                LearningRate = 0.5, MaxEpoch = iterationsCount
            };

            Backpropagation.Train(net, _trainingCfg, trainingSet, _ => { });
            var actualError = ErrorFunctions.TotalError(net, trainingSet);

            actualError.Should().BeApproximately(expectedError, Precision);
        }