Exemple #1
0
 /// <summary>
 /// Tworzenie połączeń z neuronami warstwy poprzedniej i biasem a neuronem 
 /// z warstwy kolejnej
 /// </summary>
 /// <param name="prior">neurony wartwy poprzedniej</param>
 /// <param name="neuron">nuron z wartwy kolejnej</param>
 /// <param name="bias">bias, element progowy</param>
 /// <returns></returns>
 IEnumerable<Connection> GetNeuronConnections(FirstLayerElement[] prior, Neuron neuron, Bias bias)
 {
     foreach (FirstLayerElement link in prior)
         yield return new Connection(link, neuron);
     if (bias != null)
         yield return new Connection(bias, neuron);
 }
 private IEnumerable<FirstLayerElement> gather(FirstLayerElement[][] layers, Bias bias)
 {
     foreach (FirstLayerElement[] layer in layers) {
         foreach (FirstLayerElement link in layer) {
             yield return link;
         }
     }
     if (bias != null) {
         yield return bias;
     }
     yield break;
 }
Exemple #3
0
 /// <summary>
 /// Dokonuje pełnego połączenia dwóch wartw neuronów
 /// każdy z każdym
 /// </summary>
 /// <param name="prior">warstwa poprzednia</param>
 /// <param name="next">warstwa kolejna</param>
 /// <param name="bias">bias, element progowy sieci</param>
 public void Connect(FirstLayerElement[] prior, Neuron[] next, Bias bias)
 {
     // iterowanie neuronów warstwy kolejnej i wypełnianie pola previous
     foreach (Neuron neuron in next)
         neuron.PreviousLayer = GetNeuronConnections(prior, neuron, bias).ToArray();
     int idx = 0;
     // iterowanie warstwy poprzedniej
     foreach (FirstLayerElement link in prior)
         link.NextLayer = GetLinkConnections(idx++, next).ToArray();
     if (bias != null) {
         var biasConnections = GetBiasConnections(bias, next);
         if (bias.NextLayer == null)
             bias.NextLayer = new Connection[] { };
         bias.NextLayer = bias.NextLayer.Concat(biasConnections).ToArray();
     }
 }
 public NetworkStructure(FirstLayerElement[][] layers, Bias bias)
 {
     this.Layers = layers;
     this.Bias = bias;
     this.Elements = gather(layers, bias).ToArray();
 }
Exemple #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="source">source neuron</param>
 /// <param name="destination">destination neuron</param>
 /// <param name="weight">weight of the connection</param>
 public Connection(FirstLayerElement source, Neuron destination, Weight weight)
 {
     this.Source = source;
     this.Destination = destination;
     this.Weight = weight;
 }
Exemple #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="source">source neuron</param>
 /// <param name="destination">destination neuron</param>
 public Connection(FirstLayerElement source, Neuron destination)
     : this(source, destination, new Weight())
 {
 }