public Connection(Weight weight,Link previous,NeuronBase next) { Utility.Verify(()=> weight!=null && previous!=null && next!=null); Weight=weight; Next=next; Previous=previous; }
void Connect(Link pre,Node post,Weight weight) { Connection i=new Connection(weight); pre.Next[Utility.FirstNull(pre.Next)]=i; post.Previous[Utility.FirstNull(post.Previous)]=i; i.Previous=pre; i.Next=post; i.Identity=string.Format("{0} --> {1}",i.Previous.Identity,i.Next.Identity); }
void Map(Link a,Link b,Weight weight,Dictionary<Link,List<Connection>> map) { Connection connection=new Connection(weight,a,(NeuronBase)b); if(!map.ContainsKey(a)) map[a]=new List<Connection>(); map[a].Add(connection); if(!map.ContainsKey(b)) map[b]=new List<Connection>(); map[b].Add(connection); }
void ConnectKernel(Link[] kernel,Node node,Weight[] weights, Bias bias,Dictionary<Link,int> ccd) { int l=kernel.Length; if(bias!=null) l++; node.Previous=new Connection[l]; for(var i=0;i<kernel.Length;i++) { kernel[i].Next=kernel[i].Next??new Connection[ccd[kernel[i]]]; Connect(kernel[i],node,weights[i]); } if(bias!=null) Connect(bias,node,weights[kernel.Length]); }