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")); }
public MultilayerPerceptron(NetworkStructure structure,double lo,double hi) : this(structure) { Reset(lo,hi); }
public MultilayerPerceptron(NetworkStructure structure) : base(structure) { }
public FeedForwardNetwork(NetworkStructure structure) { Utility.Verify(()=>structure!=null); Structure=structure; }
public ConvolutionalNetwork(NetworkStructure structure) : base(structure) { }
public MLPWatchdog(NetworkStructure structure) : this(structure,-1,1) { }
public MLPWatchdog(NetworkStructure structure,double lo,double hi) : base(structure,lo,hi) { Lo=lo; Hi=hi; }
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"))); } }
public MultilayerPerceptron(NetworkStructure structure, double lo, double hi) : this(structure) { Reset(lo, hi); }
public FeedForwardNetwork(NetworkStructure structure) { Utility.Verify(() => structure != null); Structure = structure; }
public ConvolutionalNetwork Deserialize(XDocument xdoc) { NetworkStructure structure = GetStructure(xdoc.Element("root")); return(new ConvolutionalNetwork(structure)); }
public MultilayerPerceptron Deserialize(XDocument xdoc) { NetworkStructure structure = GetStructure(xdoc.Element("root")); return(new MultilayerPerceptron(structure)); }