コード例 #1
0
        public static NNData XMLToDataByName(string filepath, string Name, string InNode)
        {
            /* Sucht im XML-File in filepath, in der Node InNode (muss direkt am document-root von filepath hängen), das Neural Network mit dem Namen Name)
             * und Speichert dies in einer NNData-Klasse. Aus dieser kann mit dem Konstruktor NeuralNetwork(NNData data) in ein
             * Neural Network mit den im XML-file gespeichtern eigenschaften erzeugt werden */
            NNData  data = new NNData();
            XmlNode Weights_node_xml;
            string  filesep = @"/";

            XmlDocument doc = new XmlDocument();

            doc.Load(filepath);
            XmlElement root = doc.DocumentElement;

            Weights_node_xml = doc.SelectSingleNode(InNode + filesep + Name + @"/Weights");
            var Weights_nodeList_xml = Weights_node_xml.ChildNodes;
            int size = Weights_nodeList_xml.Count;

            string NNname = Name;

            data.Weights = new float[size];

            XmlNode NumIp_xml, NumHd_xml, NumOp_xml;

            NumIp_xml = doc.SelectSingleNode(root.Name + "/" + NNname + "/NumberOfIpNeurons");
            int NIP = new int();

            NIP            = Convert.ToInt32(NumIp_xml.InnerText);
            data.NumIpNeur = NIP;

            NumHd_xml = doc.SelectSingleNode(root.Name + "/" + NNname + "/NumberOfHdNeurons");
            int NHD = new int();

            NHD            = Convert.ToInt32(NumHd_xml.InnerText);
            data.NumHdNeur = NHD;

            NumOp_xml = doc.SelectSingleNode(root.Name + "/" + NNname + "/NumberOfOpNeurons");
            int NOP = new int();

            NOP            = Convert.ToInt32(NumOp_xml.InnerText);
            data.NumOpNeur = NOP;

            var checkchildnodes = Weights_node_xml.ChildNodes;
            int i = 0;

            foreach (XmlNode w in Weights_node_xml.ChildNodes)
            {
                data.Weights[i] = float.Parse(w.InnerText);
                i++;
            }
            return(data);
        }
コード例 #2
0
 public NeuralNetwork(NNData Data) : this(Data.NumIpNeur, Data.NumHdNeur, Data.NumOpNeur, Data.Weights, Data.ActivFct)
 {
 }