Example #1
0
        public static bool Test2()
        {
            var i1 = new InputNode();
            var i2 = new InputNode();
            var h1 = new Perceptron(new Heaviside(1.0));
            var h2 = new Perceptron(new Heaviside(2.0));
            var h3 = new Perceptron(new Heaviside(1.0));

            LinearWeight.Connect(i1, h1, 1.0);
            LinearWeight.Connect(i1, h2, 1.0);
            LinearWeight.Connect(i2, h2, 1.0);
            LinearWeight.Connect(i2, h3, 1.0);
            var o = new Perceptron(new Linear());

            LinearWeight.Connect(h1, o, 1.0);
            LinearWeight.Connect(h2, o, -2.0);
            LinearWeight.Connect(h3, o, 1.0);

            var network = new GeneralNetwork(new List <InputNode> {
                i1, i2
            }, new List <INode> {
                o
            });

            network.Forward(new[] { 0.0, 0.0 });
            network.Forward(new[] { 1.0, 0.0 });
            network.Forward(new[] { 0.0, 1.0 });
            network.Forward(new[] { 1.0, 1.0 });
            return(true);
        }
Example #2
0
        public static bool Test1()
        {
            var i1 = new InputNode();
            var i2 = new InputNode();
            var h1 = new Perceptron(new Linear());
            var h2 = new Perceptron(new Linear());
            var h3 = new Perceptron(new Linear());

            LinearWeight.Connect(i1, h1, 1.0);
            LinearWeight.Connect(i1, h2, 1.0);
            LinearWeight.Connect(i2, h2, 1.0);
            LinearWeight.Connect(i2, h3, 1.0);
            var ib = new BiasNode();

            LinearWeight.Connect(ib, h1, 1.0);
            LinearWeight.Connect(ib, h2, 2.0);
            LinearWeight.Connect(ib, h3, 1.0);
            var o = new Perceptron(new Linear());

            LinearWeight.Connect(h1, o, 1.0);
            LinearWeight.Connect(h2, o, -2.0);
            LinearWeight.Connect(h3, o, 1.0);
            var hb   = new BiasNode();
            var whbo = new LinearWeight(hb, o);

            whbo[0] = 1.0;

            var network = new GeneralNetwork(new List <InputNode> {
                i1, i2
            }, new List <INode> {
                o
            });

            network.Forward(new[] { 0.0, 0.0 });
            network.Forward(new[] { 1.0, 0.0 });
            network.Forward(new[] { 0.0, 1.0 });
            network.Forward(new[] { 1.0, 1.0 });
            return(true);
        }