Ejemplo n.º 1
0
        public void should_simulate_OR_gate(float[] input, int output)
        {
            // Arrange
            _sut.SetWeights(TestWeights.OR);

            // Act
            var activation   = _sut.FeedForwards(input);
            var actualOutput = (int)Math.Round(ActivationFn.Sigmoid(activation), 0);

            // Assert
            Assert.That(actualOutput, Is.EqualTo(output));
        }
Ejemplo n.º 2
0
        public void should_simulate_XNOR_gate(float[] input, int output)
        {
            // Act
            float[] activation;

            _sut.SetWeights(TestWeights.AND);
            activation = _sut.FeedForwards(input);
            var a1 = (int)Math.Round(ActivationFn.Sigmoid(activation[0]), 0);

            _sut.SetWeights(TestWeights.NOR);
            activation = _sut.FeedForwards(input);
            var a2 = (int)Math.Round(ActivationFn.Sigmoid(activation[0]), 0);

            _sut.SetWeights(TestWeights.OR);
            activation = _sut.FeedForwards(a1, a2);
            var actualOutput = (int)Math.Round(ActivationFn.Sigmoid(activation[0]), 0);

            // Assert
            Assert.That(actualOutput, Is.EqualTo(output));
        }
Ejemplo n.º 3
0
        public void test_known_sigmoid_values(float z, float value)
        {
            var r = ActivationFn.Sigmoid(z);

            Assert.That(r, Is.EqualTo(value));
        }