geneticAlgo.indiv.getNeuron C# (CSharp) 메소드

getNeuron() 공개 메소드

public getNeuron ( int layer_num, int Neuron_num ) : Nn.Neuron
layer_num int
Neuron_num int
리턴 Nn.Neuron
        public Nn.Neuron getNeuron(int layer_num, int Neuron_num)
        {
            return Nn.getNeuron(layer_num, Neuron_num);
        }

Usage Example

예제 #1
0
 //this method will choose a random weigth of a random neuron of a random layer and modify it by a random number between -0.1 and 0.1
 public indiv mutate(indiv A)
 {
     int layer_num_mutation = rand.Next(1, A.getNbLayer());//weights of the first layer must stay 1
     int Neuron_num_mutation = rand.Next(0, A.getNbNeuronAtLayer(layer_num_mutation));
     int weigth_num_mutation = rand.Next(0, A.getNeuron(layer_num_mutation, Neuron_num_mutation).getNbWeigths());
     double mutation = (rand.NextDouble()*2-1); //mutation between -0.1 and 0.1
     indiv mutator = new indiv(A, -1);
     double newWeigth = A.getNeuron(layer_num_mutation, Neuron_num_mutation).getWeigth(weigth_num_mutation) + mutation;
     if (newWeigth > 1) newWeigth = 1;
     else if (newWeigth < -1) newWeigth = -1;
     mutator.setDataAtPos(layer_num_mutation, Neuron_num_mutation, weigth_num_mutation, newWeigth);
     return mutator;
 }