Esempio n. 1
0
        protected IEnumerable<XElement> GetElements(NetworkStructure structure)
        {
            HashSet<Connection> hsc=new HashSet<Connection>();
            int l=0;
            foreach(Link[] layer in structure.Layers) {
                foreach(Link link in layer) {
                    XElement elem=new XElement("unit",
                        new XAttribute("type",Aliases[link.GetType().ToString()]),
                        new XAttribute("layer",l.ToString()),
                        link.GetDescription());
                    if(link is NeuronBase)
                        elem.Add(new XAttribute("func",Aliases[((NeuronBase)link).Func.GetType().ToString()]));
                    yield return elem;

                    if(link.Next!=null)
                        foreach(Connection connection in link.Next)
                            hsc.Add(connection);
                    if(link is NeuronBase)
                        if(((NeuronBase)link).Previous!=null)
                            foreach(Connection connection in ((NeuronBase)link).Previous)
                                hsc.Add(connection);
                }
                l++;
            }
            if(structure.Bias!=null) {
                yield return new XElement("unit",
                    new XAttribute("type",Aliases[structure.Bias.GetType().ToString()]),
                    new XAttribute("value",structure.Bias.Value.ToString("R")),
                    structure.Bias.GetDescription());
                foreach(Connection connection in structure.Bias.Next)
                    hsc.Add(connection);

            }
            HashSet<Weight> wsw=new HashSet<Weight>();
            Dictionary<Weight,int> weightsDict=new Dictionary<Weight,int>();
            int idx=1;
            foreach(Connection connection in hsc) {
                if(!weightsDict.ContainsKey(connection.Weight))
                    weightsDict.Add(connection.Weight,idx++);
                yield return new XElement("connection",
                    new XAttribute("from",connection.Previous.GetDescription()),
                    new XAttribute("to",connection.Next.GetDescription()),
                    weightsDict[connection.Weight].ToString()
                    );
            }
            foreach(var kvp in weightsDict)
                yield return new XElement("weight",new XAttribute("type",Aliases[kvp.Key.GetType().ToString()]),new XAttribute("index",kvp.Value.ToString()),kvp.Key.Value.ToString("R"));
        }
Esempio n. 2
0
 public MultilayerPerceptron(NetworkStructure structure,double lo,double hi)
     : this(structure)
 {
     Reset(lo,hi);
 }
Esempio n. 3
0
 public MultilayerPerceptron(NetworkStructure structure)
     : base(structure)
 {
 }
Esempio n. 4
0
 public FeedForwardNetwork(NetworkStructure structure)
 {
     Utility.Verify(()=>structure!=null);
     Structure=structure;
 }
Esempio n. 5
0
 public ConvolutionalNetwork(NetworkStructure structure)
     : base(structure)
 {
 }
Esempio n. 6
0
 public MLPWatchdog(NetworkStructure structure)
     : this(structure,-1,1)
 {
 }
Esempio n. 7
0
 public MLPWatchdog(NetworkStructure structure,double lo,double hi)
     : base(structure,lo,hi)
 {
     Lo=lo;
         Hi=hi;
 }
Esempio n. 8
0
 public MultilayerPerceptron(NetworkStructure structure)
     : base(structure)
 {
 }
Esempio n. 9
0
        protected IEnumerable <XElement> GetElements(NetworkStructure structure)
        {
            HashSet <Connection> hsc = new HashSet <Connection>();
            int l = 0;

            foreach (Link[] layer in structure.Layers)
            {
                foreach (Link link in layer)
                {
                    XElement elem = new XElement("unit",
                                                 new XAttribute("type", Aliases[link.GetType().ToString()]),
                                                 new XAttribute("layer", l.ToString()),
                                                 link.GetDescription());
                    if (link is NeuronBase)
                    {
                        elem.Add(new XAttribute("func", Aliases[((NeuronBase)link).Func.GetType().ToString()]));
                    }
                    yield return(elem);

                    if (link.Next != null)
                    {
                        foreach (Connection connection in link.Next)
                        {
                            hsc.Add(connection);
                        }
                    }
                    if (link is NeuronBase)
                    {
                        if (((NeuronBase)link).Previous != null)
                        {
                            foreach (Connection connection in ((NeuronBase)link).Previous)
                            {
                                hsc.Add(connection);
                            }
                        }
                    }
                }
                l++;
            }
            if (structure.Bias != null)
            {
                yield return(new XElement("unit",
                                          new XAttribute("type", Aliases[structure.Bias.GetType().ToString()]),
                                          new XAttribute("value", structure.Bias.Value.ToString("R")),
                                          structure.Bias.GetDescription()));

                foreach (Connection connection in structure.Bias.Next)
                {
                    hsc.Add(connection);
                }
            }
            HashSet <Weight>         wsw         = new HashSet <Weight>();
            Dictionary <Weight, int> weightsDict = new Dictionary <Weight, int>();
            int idx = 1;

            foreach (Connection connection in hsc)
            {
                if (!weightsDict.ContainsKey(connection.Weight))
                {
                    weightsDict.Add(connection.Weight, idx++);
                }
                yield return(new XElement("connection",
                                          new XAttribute("from", connection.Previous.GetDescription()),
                                          new XAttribute("to", connection.Next.GetDescription()),
                                          weightsDict[connection.Weight].ToString()
                                          ));
            }
            foreach (var kvp in weightsDict)
            {
                yield return(new XElement("weight", new XAttribute("type", Aliases[kvp.Key.GetType().ToString()]), new XAttribute("index", kvp.Value.ToString()), kvp.Key.Value.ToString("R")));
            }
        }
Esempio n. 10
0
 public MultilayerPerceptron(NetworkStructure structure, double lo, double hi)
     : this(structure) {
     Reset(lo, hi);
 }
Esempio n. 11
0
 public FeedForwardNetwork(NetworkStructure structure)
 {
     Utility.Verify(() => structure != null);
     Structure = structure;
 }
Esempio n. 12
0
        public ConvolutionalNetwork Deserialize(XDocument xdoc)
        {
            NetworkStructure structure = GetStructure(xdoc.Element("root"));

            return(new ConvolutionalNetwork(structure));
        }
Esempio n. 13
0
 public ConvolutionalNetwork(NetworkStructure structure)
     : base(structure)
 {
 }
Esempio n. 14
0
        public MultilayerPerceptron Deserialize(XDocument xdoc)
        {
            NetworkStructure structure = GetStructure(xdoc.Element("root"));

            return(new MultilayerPerceptron(structure));
        }