Beispiel #1
0
        public void Load_and_Generate(string Path)
        {
            XPathDocument  doc = new XPathDocument(Path);
            XPathNavigator nav = doc.CreateNavigator();

            // Compile a standard XPath expression
            XPathExpression expr;

            expr = nav.Compile("/network");
            XPathNodeIterator iterator = nav.Select(expr);

            if (MF == null)
            {
                MF = new MainForm();
            }
            MF.Manager = new Layers_Manager();
            while (iterator.MoveNext())
            {
                XPathNavigator nav2 = iterator.Current.Clone();
                nav2.MoveToFirstChild();
                MF.Manager.InputSlotSize = Convert.ToInt32(nav2.Value);
                MF.NUDInputSlot.Value    = (decimal)MF.Manager.InputSlotSize;
                nav2.MoveToNext();
                MF.Manager.MaxError = (float)Convert.ToDouble(nav2.Value);
                while (nav2.MoveToNext() && nav2.Name == "layer")
                {
                    nav2.MoveToFirstChild();
                    Layer L = new Layer(Convert.ToInt32(nav2.Value));
                    nav2.MoveToNext();
                    if (nav2.Value == "Hidden")
                    {
                        L.LayerType = Neuron.NeuronType.Hidden;
                    }
                    else
                    {
                        L.LayerType = Neuron.NeuronType.Output;
                    }
                    while (nav2.MoveToNext() && nav2.Name == "neuron")
                    {
                        nav2.MoveToFirstChild();
                        Neuron N = new Neuron();
                        N.ParentLayer_Ref = L;
                        N.Initialize(L.LayerType);
                        N.ID = Convert.ToInt32(nav2.Value);
                        nav2.MoveToNext();
                        N.InputCount = Convert.ToInt32(nav2.Value);
                        nav2.MoveToNext();
                        N.LearningRate = (float)Convert.ToDouble(nav2.Value);
                        nav2.MoveToNext();
                        N.Tag = nav2.Value;
                        nav2.MoveToNext();
                        N.Bias = (float)Convert.ToDouble(nav2.Value);
                        N.Weights.Add(N.Bias);
                        for (int i = 0; i < N.InputCount; i++)
                        {
                            N.Weights.Add(0);
                            N.OldWeights.Add(0);
                        }
                        L.Neurons.Add(N);
                        L.Count++;
                        nav2.MoveToParent();
                    }
                    L.InitializeLayer();
                    MF.Manager.Layers.Add(L);
                    nav2.MoveToParent();
                }
                foreach (Layer L in MF.Manager.Layers)
                {
                    L.MaxID = MF.Manager.Layers.Count;
                }
            }
            TSSStatusLbl.Text = "Network Loaded Successfully ...";
        }