Beispiel #1
0
        static void Main()
        {
            Network xorNet = new Network("res/mininet.txt");
            Console.WriteLine(xorNet.output.ToString());

            double[][] testMatrix = new double[][]{
                                   new double[] { 0.0, 0.0 },
                                   new double[] { 0.0, 1.0 },
                                   new double[] { 1.0, 0.0 },
                                   new double[] { 1.0, 1.0 }
                                   };

            foreach(double[] sample in testMatrix){
                xorNet.computeNetwork(sample);
                Console.WriteLine(string.Format("Input {0}, output {1}",sample.ToString(), xorNet.output.ToString()));
            }
            //myANN.doFeedForward();
            /*double []v = new double[2];

            v[0] = 0;
            v[1] = 0;
            myANN.computeNetwork(v);
            Console.WriteLine(myANN.output.ToString());
             * */
            Console.Read();
        }
Beispiel #2
0
        public Network(Network n)
        {
            this.actionList = new List<IAction>();
            foreach(IAction ac in n.actionList){
                if (ac.GetType() == typeof(Layer))
                {
                    Layer acLayer = (Layer)ac;
                    Layer aux = new Layer(acLayer);
                    this.actionList.Add(aux);

                    if (acLayer == n.input)
                    {
                        this.input = aux;

                    }
                    else if (acLayer == n.output)
                    {

                        this.output = aux;
                    }
                }
                else
                {
                    this.actionList.Add(ac);
                }

            }
        }
Beispiel #3
0
        public static Network fromDescription(string description)
        {
            Network network = new Network();

            string[] desc = description.Split();

            int idx = 0;
            Layer ant = null;

            while (idx < desc.Length)
            {
                int nNeurons = Int32.Parse(desc[idx++]);
                string sAct = desc[idx++];
                ActivationFunction fAct = Layer.stringToActivation(sAct);

                if (ant == null)
                {
                    network.input = new Layer(nNeurons, fAct);
                    ant = network.input;
                    continue;
                }

                Layer newLayer = new Layer(nNeurons, fAct);

                Connections newConnection = new Connections(ant, newLayer);
                network.actionList.Add(newConnection);

                network.actionList.Add(newLayer);

                ant = newLayer;

            }

            network.output = ant;
            return network;
        }