/// <summary> /// Berechnet den Wert der Nachbarschaftsfunktion /// </summary> /// <param name="z">Abstand (Norm) zum Gewinner-Neuron</param> /// <param name="d">DistanzParameter (Radius)</param> /// <param name="selFkt">Selektierte Nachbarschaftsfunktion</param> /// <returns></returns> private double hcFkt(double z, double d, net_hFkt selFkt) { double h = 0; switch (selFkt) { case net_hFkt.hgauss1: { h = Math.Exp(-Math.Pow(z / d, 2)); break; } case net_hFkt.hcylinder: { h = z < d ? 1 : 0; break; } case net_hFkt.hcone: { h = z < d ? 1 - (z / d) : 0; break; } case net_hFkt.hcos: { h = z < d?Math.Cos((z / d) *(Math.PI / 2)) : 0; break; } } return(h); }
public void train_RecordSet(List <RecordSet> myRecs, net_hFkt neighbourFkt, int Cycles) { for (int cyc = 0; cyc < Cycles; cyc++) { for (int i = 0; i < myRecs.Count; i++) { train_Pattern(myRecs[i].InputVec, net_hFkt.hgauss1, 5); myRecs[i].AddRecordSetToNeuron(net_BmNeuron.BM_Neuron); } } }
/// <summary> /// Trainiert das Netz zu dem repräsentierten Eingabe-Pattern /// </summary> /// <param name="InputVec">Eingabe-Vektor X (Lern-Pattern)</param> public void train_Pattern(Vector InputVec, net_hFkt neighbourFkt, double radius) { double mu = 0.6; Calculate_BestMatching(InputVec, Convert.ToInt32(radius)); //auch nur so lange korrigieren wie Neuronen vorhanden, bzw. auch nur im Radius (abhängig von der Dimension) sich befinden for (int i = 0; i < Neurons.Count && i < radius * Neurons[0].Position.Dimension * 2 + 1; i++) { Neurons[i].WeightVec = Neurons[i].WeightVec + mu * hcFkt((net_BmNeuron.Position - Neurons[i].Position).Euklid(), radius == 0 ? 1 : radius, neighbourFkt) * (InputVec - Neurons[i].WeightVec); } }