Exemple #1
0
        public Net(int Inputs, int Outputs, int Layers = 3)
        {
            if (Layers < 2)
                throw new ArgumentException("There must be at least 2 layers.");

            this.Inputs = Inputs;
            this.Outputs = Outputs;

            NodeLayers = new NodeLayer[Layers];
            for (int i = 0; i < Layers - 1; i++)
            {
                NodeLayers[i] = new NodeLayer(Inputs, Inputs);
            }
            NodeLayers[Layers - 1] = new NodeLayer(Inputs, Outputs);
        }
        public void LogicNodeLayerOR()
        {
            INodeLayer NodeLayer = new NodeLayer(2, 1);

            BackPropagation prop = new BackPropagation(2, 1);
            DataSet _1 = new DataSet(new double[] { 0, 0 }, new double[] { 0 });    // 0 | 0 = 0
            DataSet _2 = new DataSet(new double[] { 0, 1 }, new double[] { 1 });    // 0 | 1 = 1
            DataSet _3 = new DataSet(new double[] { 1, 0 }, new double[] { 1 });    // 1 | 0 = 1
            DataSet _4 = new DataSet(new double[] { 1, 1 }, new double[] { 1 });    // 1 | 1 = 1

            prop.AddDataSet(_1);
            prop.AddDataSet(_2);
            prop.AddDataSet(_3);
            prop.AddDataSet(_4);

            int epoch = 1000;
            double SSE = prop.Train(NodeLayer, epoch);

            Assert.IsTrue(SSE < 0.2, "LogicNodeOR SSE after {0} epochs is '{1}'", epoch, SSE);
        }