Exemplo n.º 1
0
        public void CrossEntropyError_ThrowOnLengthMismatch()
        {
            var target = new[] { 1.0, 1.0 };
            var output = new[] { 1.0 };

            Assert.Throws <NeuralNetworkException>(() => ErrorCalculations.CrossEntropyError(target, output));
        }
Exemplo n.º 2
0
        public void CrossEntropyError_Calculate()
        {
            var target = new[] { 0.05, 0.8, 0.15 };
            var output = new[] { 0.3, 0.5, 0.2 };

            var actual   = ErrorCalculations.CrossEntropyError(target, output);
            var expected = 0.856132071529368;

            Assert.Equal(expected, actual, 12);
        }
Exemplo n.º 3
0
        public static double GetError(INeuralNetwork nn, IList <InputOutput> testSet)
        {
            var error = 0.0;

            foreach (var inputOutput in testSet)
            {
                var result = nn.FeedForward(inputOutput.Input);
                error += ErrorCalculations.CrossEntropyError(inputOutput.Output, result.Output);
            }

            return(error / testSet.Count);
        }
Exemplo n.º 4
0
 public static double GetCrossEntropyError(double[] expected, double[] actual)
 {
     return(ErrorCalculations.CrossEntropyError(expected, actual));
 }