Beispiel #1
0
        public static Synapse Connect(Neuron n1, Neuron n2, float weight, int delay, ILearningRule learningRule)
        {
            Synapse syn = new Synapse(n1, n2, weight, delay, learningRule.GetCopy());

            n1.AddPostSynapse(syn);
            n2.AddPreSynapse(syn);
            return(syn);
        }
Beispiel #2
0
 public static void MakeConnection(Group sourceGroup, Group destinationGroup, float weight, int delay,
                                   ConnectionPatternDelegate connectionPattern,
                                   ILearningRule learningRule)
 {
     for (int i = 0; i < sourceGroup.Count; i++)
     {
         for (int j = 0; j < destinationGroup.Count; j++)
         {
             if (connectionPattern(i, j))
             {
                 Synapse syn = new Synapse(sourceGroup[i], destinationGroup[j],
                                           weight, delay, learningRule.GetCopy());
                 sourceGroup[i].AddPostSynapse(syn);
                 destinationGroup[j].AddPreSynapse(syn);
             }
         }
     }
 }
Beispiel #3
0
        public static void MakeSharedConnection(Group sourceGroup, Group destinationGroup,
                                                ConnectionPatternDelegate connectionPattern, List <SynapseCore> synapseCores)
        {
            int coreIdx = 0;

            for (int i = 0; i < destinationGroup.Count; i++)
            {
                for (int j = 0; j < sourceGroup.Count; j++)
                {
                    if (connectionPattern(j, i))
                    {
                        Synapse syn = new Synapse(sourceGroup[j], destinationGroup[i], synapseCores[coreIdx]);
                        sourceGroup[j].AddPostSynapse(syn);
                        destinationGroup[i].AddPreSynapse(syn);
                        coreIdx++;
                    }
                }
            }
        }
Beispiel #4
0
        public static void MakeRandomValueConnection(Group sourceGroup, Group destinationGroup,
                                                     float minWeight, float maxWeight, int minDelay, int maxDelay,
                                                     ConnectionPatternDelegate connectionPattern, ILearningRule learningRule)
        {
            float range = maxWeight - minWeight;

            for (int i = 0; i < sourceGroup.Count; i++)
            {
                for (int j = 0; j < destinationGroup.Count; j++)
                {
                    if (connectionPattern(i, j))
                    {
                        float   randWeight = (float)rand.NextDouble() * range + minWeight;
                        int     randDelay  = rand.Next(minDelay, maxDelay + 1);
                        Synapse syn        = new Synapse(sourceGroup[i], destinationGroup[j],
                                                         randWeight, randDelay, learningRule.GetCopy());
                        sourceGroup[i].AddPostSynapse(syn);
                        destinationGroup[j].AddPreSynapse(syn);
                    }
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// Adds a new post synapse.
 /// </summary>
 /// <param name="postSynapse">Synapse information</param>
 public void AddPostSynapse(Synapse postSynapse)
 {
     postSynapses.Add(postSynapse);
 }
Beispiel #6
0
 /// <summary>
 /// Adds a new pre synapse.
 /// </summary>
 /// <param name="preSynapse">Synapse information</param>
 public void AddPreSynapse(Synapse preSynapse)
 {
     preSynapses.Add(preSynapse);
 }
 public SynapseStatistics(Synapse targetSynapse)
 {
     this.synapse = targetSynapse;
 }
        public void ApplyLearningRule(Synapse synapse)
        {
            float dW = learningRule.GetWeightChange(synapse);

            Weight += dW;
        }