pyerualjetwork 4.2.6b8__py3-none-any.whl → 4.2.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- __version__ = "4.2.6b8"
1
+ __version__ = "4.2.7"
2
2
  __update__ = "* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES\n* PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main\n* PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf\n* YouTube tutorials: https://www.youtube.com/@HasanCanBeydili"
3
3
 
4
4
  def print_version(__version__):
pyerualjetwork/planeat.py CHANGED
@@ -81,18 +81,19 @@ def evolver(weights,
81
81
  bad_genomes_selection_prob=None,
82
82
  bar_status=True,
83
83
  strategy='normal_selective',
84
- bad_genomes_mutation_prob=None,
85
- activation_mutate_prob=0.5,
86
- fitness_bias=None,
87
- cross_over_mode='tpm',
84
+ bad_genomes_mutation_prob=None,
85
+ fitness_bias=1,
86
+ cross_over_mode='tpm',
88
87
  activation_mutate_add_prob=0.5,
89
88
  activation_mutate_delete_prob=0.5,
90
- activation_mutate_change_prob=0.5,
91
- weight_mutate_prob=1,
92
- weight_mutate_rate=32,
93
- activation_selection_add_prob=0.6,
94
- activation_selection_change_prob=0.4,
95
- activation_selection_rate=2,
89
+ activation_mutate_change_prob=0.5,
90
+ activation_selection_add_prob=0.7,
91
+ activation_selection_change_prob=0.5,
92
+ activation_selection_threshold=2,
93
+ activation_mutate_prob=1,
94
+ activation_mutate_threshold=2,
95
+ weight_mutate_threshold=16,
96
+ weight_mutate_prob=1,
96
97
  dtype=np.float32):
97
98
  """
98
99
  Applies the evolving process of a population of genomes using selection, crossover, mutation, and activation function potentiation.
@@ -138,21 +139,21 @@ def evolver(weights,
138
139
 
139
140
  Default: 'aggressive'.
140
141
 
141
- fitness_bias (float, optional): Fitness bias must be a probability value between 0 and 1 that determines the effect of fitness on the crossover process. Default: Determined by the `strategy`.
142
+ fitness_bias (float, optional): Fitness bias must be a probability value between 0 and 1 that determines the effect of fitness on the crossover process. Default: 1.
142
143
 
143
144
  bad_genomes_mutation_prob (float, optional): The probability of applying mutation to the bad genomes.
144
145
  Must be in the range [0, 1]. Also affects the mutation probability of the best genomes inversely.
145
146
  For example, a value of 0.7 for bad genomes implies 0.3 for best genomes. Default: Determined by `policy`.
146
147
 
147
148
  activation_mutate_prob (float, optional): The probability of applying mutation to the activation functions.
148
- Must be in the range [0, 1]. Default is 0.5 (50%).
149
+ Must be in the range [0, 1]. Default is 1 (%100).
149
150
 
150
151
  cross_over_mode (str, optional): Specifies the crossover method to use. Options:
151
152
  - 'tpm': Two-Point Matrix Crossover.
152
153
  Default is 'tpm'.
153
154
 
154
155
  activation_mutate_add_prob (float, optional): The probability of adding a new activation function to the genome for mutation.
155
- Must be in the range [0, 1]. Default is 0.5.
156
+ Must be in the range [0, 1]. Default is 0.7.
156
157
 
157
158
  activation_mutate_delete_prob (float, optional): The probability of deleting an existing activation function
158
159
  from the genome for mutation. Must be in the range [0, 1]. Default is 0.5.
@@ -161,21 +162,21 @@ def evolver(weights,
161
162
  Must be in the range [0, 1]. Default is 0.5.
162
163
 
163
164
  weight_mutate_prob (float, optional): The probability of mutating a weight in the genome.
164
- Must be in the range [0, 1]. Default is 1.
165
+ Must be in the range [0, 1]. Default is 1 (%100).
165
166
 
166
- weight_mutate_rate (int, optional): If the value entered here equals the result of input_layer * output_layer,
167
- only a single weight will be mutated during each mutation process. If the value is half of the result,
168
- two weights will be mutated. WARNING: If you don't understand, do NOT change this value. Default is 32.
167
+ weight_mutate_threshold (int): Determines max how much weight mutaiton operation applying. (Function automaticly determines to min) Default: 16
169
168
 
170
169
  activation_selection_add_prob (float, optional): The probability of adding an existing activation function for crossover.
171
- Must be in the range [0, 1]. Default is 0.6. (WARNING! Higher values increase complexity. For faster training, increase this value.)
170
+ Must be in the range [0, 1]. Default is 0.5. (WARNING! Higher values increase complexity. For faster training, increase this value.)
172
171
 
173
172
  activation_selection_change_prob (float, optional): The probability of changing an activation function in the genome for crossover.
174
- Must be in the range [0, 1]. Default is 0.4.
173
+ Must be in the range [0, 1]. Default is 0.5.
175
174
 
176
- activation_selection_rate (int, optional): If the activation list of a good genome is smaller than this value, only one activation will undergo crossover. This parameter controls model complexity. Default is 2.
175
+ activation_mutate_threshold (int, optional): Determines max how much activation mutaiton operation applying. (Function automaticly determines to min) Default: 2
176
+
177
+ activation_selection_threshold (int, optional): Determines max how much activaton transferable to child from undominant parent. (Function automaticly determines to min) Default: 2
177
178
 
178
- dtype (numpy.dtype): Data type for the arrays. Default: np.float32.
179
+ dtype (numpy.dtype, optional): Data type for the arrays. Default: np.float32.
179
180
  Example: np.float64 or np.float16 [fp32 for balanced devices, fp64 for strong devices, fp16 for weak devices: not recommended!].
180
181
 
181
182
  Raises:
@@ -223,17 +224,14 @@ def evolver(weights,
223
224
  if strategy == 'normal_selective':
224
225
  if bad_genomes_mutation_prob is None: bad_genomes_mutation_prob = 0.7 # EFFECTS MUTATION
225
226
  if bad_genomes_selection_prob is None: bad_genomes_selection_prob = 0.25 # EFFECTS CROSS-OVER
226
- if fitness_bias is None: fitness_bias = 0.5 # The pressure applied by FITNESS to the CROSS-OVER
227
-
227
+
228
228
  elif strategy == 'more_selective':
229
229
  if bad_genomes_mutation_prob is None: bad_genomes_mutation_prob = 0.85 # EFFECTS MUTATION
230
230
  if bad_genomes_selection_prob is None: bad_genomes_selection_prob = 0.1 # EFFECTS CROSS-OVER
231
- if fitness_bias is None: fitness_bias = 0.7 # The pressure applied by FITNESS to the CROSS-OVER
232
231
 
233
232
  elif strategy == 'less_selective':
234
233
  if bad_genomes_mutation_prob is None: bad_genomes_mutation_prob = 0.6 # EFFECTS MUTATION
235
234
  if bad_genomes_selection_prob is None: bad_genomes_selection_prob = 0.5 # EFFECTS CROSS-OVER
236
- if fitness_bias is None: fitness_bias = 0.3 # The pressure applied by FITNESS to the CROSS-OVER
237
235
 
238
236
  else:
239
237
  raise ValueError("strategy parameter must be: 'normal_selective' or 'more_selective' or 'less_selective'")
@@ -250,11 +248,11 @@ def evolver(weights,
250
248
  if fitness_bias < 0 or fitness_bias > 1: raise ValueError("fitness_bias value must be a number between 0 and 1.")
251
249
 
252
250
  if bad_genomes_mutation_prob is not None:
253
- if not isinstance(bad_genomes_mutation_prob, float) or bad_genomes_mutation_prob < 0 or bad_genomes_mutation_prob > 1:
251
+ if bad_genomes_mutation_prob < 0 or bad_genomes_mutation_prob > 1:
254
252
  raise ValueError("bad_genomes_mutation_prob parameter must be float and 0-1 range")
255
253
 
256
254
  if activation_mutate_prob is not None:
257
- if not isinstance(activation_mutate_prob, float) or activation_mutate_prob < 0 or activation_mutate_prob > 1:
255
+ if activation_mutate_prob < 0 or activation_mutate_prob > 1:
258
256
  raise ValueError("activation_mutate_prob parameter must be float and 0-1 range")
259
257
 
260
258
  if len(fitness) % 2 == 0:
@@ -321,7 +319,7 @@ def evolver(weights,
321
319
  cross_over_mode=cross_over_mode,
322
320
  activation_selection_add_prob=activation_selection_add_prob,
323
321
  activation_selection_change_prob=activation_selection_change_prob,
324
- threshold=activation_selection_rate,
322
+ activation_selection_threshold=activation_selection_threshold,
325
323
  bad_genomes_selection_prob=bad_genomes_selection_prob,
326
324
  first_parent_fitness=best_fitness,
327
325
  fitness_bias=fitness_bias,
@@ -350,8 +348,10 @@ def evolver(weights,
350
348
  activation_delete_prob=activation_mutate_delete_prob,
351
349
  activation_change_prob=activation_mutate_change_prob,
352
350
  weight_mutate_prob=weight_mutate_prob,
353
- threshold=weight_mutate_rate,
354
- genome_fitness=normalized_fitness[fitness_index]
351
+ weight_mutate_threshold=weight_mutate_threshold,
352
+ genome_fitness=normalized_fitness[fitness_index],
353
+ activation_mutate_threshold=activation_mutate_threshold,
354
+ epsilon=epsilon
355
355
  )
356
356
 
357
357
  if bar_status: progress.update(1)
@@ -375,15 +375,16 @@ def evolver(weights,
375
375
  print(" GOOD GENOMES MUTATION PROB: ", str(round(1 - bad_genomes_mutation_prob, 2)))
376
376
  print(" BAD GENOMES SELECTION PROB: ", str(bad_genomes_selection_prob))
377
377
  print(" WEIGHT MUTATE PROB: ", str(weight_mutate_prob))
378
- print(" WEIGHT MUTATE RATE (THRESHOLD VALUE FOR SINGLE MUTATION): ", str(weight_mutate_rate))
378
+ print(" WEIGHT MUTATE THRESHOLD: ", str(weight_mutate_threshold))
379
379
  print(" ACTIVATION MUTATE PROB: ", str(activation_mutate_prob))
380
+ print(" ACTIVATION MUTATE THRESHOLD: ", str(activation_mutate_threshold))
380
381
  print(" ACTIVATION MUTATE ADD PROB: ", str(activation_mutate_add_prob))
381
382
  print(" ACTIVATION MUTATE DELETE PROB: ", str(activation_mutate_delete_prob))
382
383
  print(" ACTIVATION MUTATE CHANGE PROB: ", str(activation_mutate_change_prob))
384
+ print(" ACTIVATION SELECTION THRESHOLD:", str(activation_selection_threshold))
383
385
  print(" ACTIVATION SELECTION ADD PROB: ", str(activation_selection_add_prob))
384
386
  print(" ACTIVATION SELECTION CHANGE PROB: ", str(activation_selection_change_prob))
385
- print(" FITNESS BIAS: ", str(fitness_bias))
386
- print(" ACTIVATION SELECTION RATE (THRESHOLD VALUE FOR SINGLE CROSS OVER):", str(activation_selection_rate) + '\n')
387
+ print(" FITNESS BIAS: ", str(fitness_bias) + '\n')
387
388
 
388
389
 
389
390
  print("*** Performance ***")
@@ -477,7 +478,7 @@ def cross_over(first_parent_W,
477
478
  cross_over_mode,
478
479
  activation_selection_add_prob,
479
480
  activation_selection_change_prob,
480
- threshold,
481
+ activation_selection_threshold,
481
482
  bad_genomes_selection_prob,
482
483
  first_parent_fitness,
483
484
  second_parent_fitness,
@@ -506,8 +507,7 @@ def cross_over(first_parent_W,
506
507
  activation_selection_change_prob (float): Probability of replacing an activation function in the child genome
507
508
  with one from the second parent.
508
509
 
509
- threshold (float): Determines how quickly activation functions are added or replaced
510
- during the crossover process.
510
+ activation_selection_threshold (float): (float): Determines max how much activaton transferable to child from undominant parent. (Function automaticly determines to min)
511
511
 
512
512
  bad_genomes_selection_prob (float): Probability of selecting a "bad" genome for replacement with the offspring.
513
513
 
@@ -539,7 +539,7 @@ def cross_over(first_parent_W,
539
539
  cross_over_mode='tpm',
540
540
  activation_selection_add_prob=0.8,
541
541
  activation_selection_change_prob=0.5,
542
- threshold=2,
542
+ activation_selection_threshold=2,
543
543
  bad_genomes_selection_prob=0.7,
544
544
  first_parent_fitness=0.9,
545
545
  second_parent_fitness=0.85,
@@ -614,7 +614,7 @@ def cross_over(first_parent_W,
614
614
 
615
615
  if potential_activation_selection_add > activation_selection_add_prob:
616
616
 
617
- threshold = abs(threshold / succes)
617
+ threshold = abs(activation_selection_threshold / succes)
618
618
  new_threshold = threshold
619
619
 
620
620
  while True:
@@ -626,7 +626,6 @@ def cross_over(first_parent_W,
626
626
 
627
627
  if len(dominant_parent_act) > new_threshold:
628
628
  new_threshold += threshold
629
- pass
630
629
 
631
630
  else:
632
631
  break
@@ -636,7 +635,7 @@ def cross_over(first_parent_W,
636
635
 
637
636
  if potential_activation_selection_change_prob > activation_selection_change_prob:
638
637
 
639
- threshold = abs(threshold / succes)
638
+ threshold = abs(activation_selection_threshold / succes)
640
639
  new_threshold = threshold
641
640
 
642
641
  while True:
@@ -649,7 +648,6 @@ def cross_over(first_parent_W,
649
648
 
650
649
  if len(dominant_parent_act) > new_threshold:
651
650
  new_threshold += threshold
652
- pass
653
651
 
654
652
  else:
655
653
  break
@@ -663,9 +661,10 @@ def mutation(weight,
663
661
  activation_delete_prob,
664
662
  activation_change_prob,
665
663
  weight_mutate_prob,
666
- threshold,
667
- genome_fitness
668
- ):
664
+ weight_mutate_threshold,
665
+ genome_fitness,
666
+ activation_mutate_threshold,
667
+ epsilon):
669
668
  """
670
669
  Performs mutation on the given weight matrix and activation functions.
671
670
  - The weight matrix is mutated by randomly changing its values based on the mutation probability.
@@ -686,9 +685,13 @@ def mutation(weight,
686
685
 
687
686
  weight_mutate_prob (float): The probability of mutating weight matrix.
688
687
 
689
- threshold (float): If the value you enter here is equal to the result of input layer * output layer, only a single weight will be mutated during each mutation process. If the value you enter here is half of the result of input layer * output layer, two weights in the weight matrix will be mutated.
688
+ weight_mutate_threshold (float): Determines max how much weight mutaiton operation applying. (Function automaticly determines to min)
690
689
 
691
- genome_fitness (float): Fitness value of genome
690
+ genome_fitness (float): Fitness (0-1) value of genome
691
+
692
+ activation_mutate_threshold (float): Determines max how much activation mutaiton operation applying. (Function automaticly determines to min)
693
+
694
+ epsilon (float): Small epsilon constant
692
695
 
693
696
  Returns:
694
697
  tuple: A tuple containing:
@@ -720,7 +723,7 @@ def mutation(weight,
720
723
 
721
724
  max_threshold = row_end * col_end
722
725
 
723
- threshold = threshold * genome_fitness
726
+ threshold = weight_mutate_threshold * genome_fitness
724
727
  new_threshold = threshold
725
728
 
726
729
  for _ in range(max_threshold):
@@ -729,57 +732,72 @@ def mutation(weight,
729
732
  selected_col = int(random.uniform(start, col_end))
730
733
 
731
734
  weight[selected_row, selected_col] = random.uniform(-1, 1)
735
+ new_threshold += threshold
732
736
 
733
737
  if max_threshold > new_threshold:
734
- new_threshold += threshold
738
+ pass
735
739
 
736
740
  else:
737
741
  break
738
742
 
739
-
740
- activation_mutate_prob = 1 - activation_mutate_prob
741
- potential_activation_mutation = random.uniform(0, 1)
743
+ activation_mutate_prob = 1 - activation_mutate_prob
744
+ potential_activation_mutation = random.uniform(0, 1)
742
745
 
743
- if potential_activation_mutation > activation_mutate_prob:
744
-
745
- except_this = ['spiral', 'circular']
746
- all_acts = [item for item in all_activations() if item not in except_this] # SPIRAL AND CIRCULAR ACTIVATION DISCARDED
747
-
748
- activation_add_prob = 1 - activation_add_prob
749
- activation_delete_prob = 1 - activation_delete_prob
750
- activation_change_prob = 1 - activation_change_prob
746
+ if potential_activation_mutation > activation_mutate_prob:
747
+
748
+ genome_fitness += epsilon
749
+ threshold = abs(activation_mutate_threshold / genome_fitness)
750
+ max_threshold = len(activations)
751
751
 
752
- potential_activation_add_prob = random.uniform(0, 1)
753
- potential_activation_delete_prob = random.uniform(0, 1)
754
- potential_activation_change_prob = random.uniform(0, 1)
752
+ new_threshold = threshold
755
753
 
756
- if potential_activation_add_prob > activation_add_prob:
754
+ except_this = ['spiral', 'circular']
755
+ all_acts = [item for item in all_activations() if item not in except_this] # SPIRAL AND CIRCULAR ACTIVATION DISCARDED
756
+
757
+ activation_add_prob = 1 - activation_add_prob
758
+ activation_delete_prob = 1 - activation_delete_prob
759
+ activation_change_prob = 1 - activation_change_prob
757
760
 
758
- try:
759
-
760
- random_index_all_act = int(random.uniform(0, len(all_acts)-1))
761
- activations.append(all_acts[random_index_all_act])
761
+ for _ in range(max_threshold):
762
762
 
763
- except:
763
+ potential_activation_add_prob = random.uniform(0, 1)
764
+ potential_activation_delete_prob = random.uniform(0, 1)
765
+ potential_activation_change_prob = random.uniform(0, 1)
764
766
 
765
- activation = activations
766
- activations = []
767
767
 
768
- activations.append(activation)
769
- activations.append(all_acts[int(random.uniform(0, len(all_acts)-1))])
770
-
771
- if potential_activation_delete_prob > activation_delete_prob and len(activations) > 1:
772
-
773
- random_index = random.randint(0, len(activations) - 1)
774
- activations.pop(random_index)
775
-
776
-
777
- if potential_activation_change_prob > activation_change_prob:
778
-
779
- random_index_all_act = int(random.uniform(0, len(all_acts)-1))
780
- random_index_genom_act = int(random.uniform(0, len(activations)-1))
768
+ if potential_activation_delete_prob > activation_delete_prob and len(activations) > 1:
769
+
770
+ random_index = random.randint(0, len(activations) - 1)
771
+ activations.pop(random_index)
772
+
773
+
774
+ if potential_activation_add_prob > activation_add_prob:
775
+
776
+ try:
777
+
778
+ random_index_all_act = int(random.uniform(0, len(all_acts)-1))
779
+ activations.append(all_acts[random_index_all_act])
780
+
781
+ except:
782
+
783
+ activation = activations
784
+ activations = []
785
+
786
+ activations.append(activation)
787
+ activations.append(all_acts[int(random.uniform(0, len(all_acts)-1))])
788
+
789
+
790
+ if potential_activation_change_prob > activation_change_prob:
791
+
792
+ random_index_all_act = int(random.uniform(0, len(all_acts)-1))
793
+ random_index_genom_act = int(random.uniform(0, len(activations)-1))
794
+
795
+ activations[random_index_genom_act] = all_acts[random_index_all_act]
796
+
797
+ new_threshold += threshold
781
798
 
782
- activations[random_index_genom_act] = all_acts[random_index_all_act]
799
+ if max_threshold > new_threshold: pass
800
+ else: break
783
801
 
784
802
  return weight, activations
785
803
 
@@ -83,18 +83,19 @@ def evolver(weights,
83
83
  bad_genomes_selection_prob=None,
84
84
  bar_status=True,
85
85
  strategy='normal_selective',
86
- bad_genomes_mutation_prob=None,
87
- activation_mutate_prob=0.5,
88
- fitness_bias=None,
86
+ bad_genomes_mutation_prob=None,
87
+ fitness_bias=1,
89
88
  cross_over_mode='tpm',
90
89
  activation_mutate_add_prob=0.5,
91
90
  activation_mutate_delete_prob=0.5,
92
- activation_mutate_change_prob=0.5,
91
+ activation_mutate_change_prob=0.5,
92
+ activation_selection_add_prob=0.7,
93
+ activation_selection_change_prob=0.5,
94
+ activation_selection_threshold=2,
95
+ activation_mutate_prob=1,
96
+ activation_mutate_threshold=2,
97
+ weight_mutate_threshold=16,
93
98
  weight_mutate_prob=1,
94
- weight_mutate_rate=32,
95
- activation_selection_add_prob=0.6,
96
- activation_selection_change_prob=0.4,
97
- activation_selection_rate=2,
98
99
  dtype=cp.float32):
99
100
  """
100
101
  Applies the evolving process of a population of genomes using selection, crossover, mutation, and activation function potentiation.
@@ -140,7 +141,7 @@ def evolver(weights,
140
141
 
141
142
  Default: 'aggressive'.
142
143
 
143
- fitness_bias (float, optional): Fitness bias must be a probability value between 0 and 1 that determines the effect of fitness on the crossover process. Default: Determined by the `strategy`.
144
+ fitness_bias (float, optional): Fitness bias must be a probability value between 0 and 1 that determines the effect of fitness on the crossover process. Default: 1`.
144
145
 
145
146
  bad_genomes_mutation_prob (float, optional): The probability of applying mutation to the bad genomes.
146
147
  Must be in the range [0, 1]. Also affects the mutation probability of the best genomes inversely.
@@ -154,7 +155,7 @@ def evolver(weights,
154
155
  Default is 'tpm'.
155
156
 
156
157
  activation_mutate_add_prob (float, optional): The probability of adding a new activation function to the genome for mutation.
157
- Must be in the range [0, 1]. Default is 0.5.
158
+ Must be in the range [0, 1]. Default is 0.7.
158
159
 
159
160
  activation_mutate_delete_prob (float, optional): The probability of deleting an existing activation function
160
161
  from the genome for mutation. Must be in the range [0, 1]. Default is 0.5.
@@ -163,19 +164,19 @@ def evolver(weights,
163
164
  Must be in the range [0, 1]. Default is 0.5.
164
165
 
165
166
  weight_mutate_prob (float, optional): The probability of mutating a weight in the genome.
166
- Must be in the range [0, 1]. Default is 1.
167
+ Must be in the range [0, 1]. Default is 1 (%100).
167
168
 
168
- weight_mutate_rate (int, optional): If the value entered here equals the result of input_layer * output_layer,
169
- only a single weight will be mutated during each mutation process. If the value is half of the result,
170
- two weights will be mutated. WARNING: If you don't understand, do NOT change this value. Default is 32.
169
+ weight_mutate_threshold (int): Determines max how much weight mutaiton operation applying. (Function automaticly determines to min) Default: 16
171
170
 
172
171
  activation_selection_add_prob (float, optional): The probability of adding an existing activation function for crossover.
173
- Must be in the range [0, 1]. Default is 0.6. (WARNING! Higher values increase complexity. For faster training, increase this value.)
172
+ Must be in the range [0, 1]. Default is 0.5. (WARNING! Higher values increase complexity. For faster training, increase this value.)
174
173
 
175
174
  activation_selection_change_prob (float, optional): The probability of changing an activation function in the genome for crossover.
176
- Must be in the range [0, 1]. Default is 0.4.
175
+ Must be in the range [0, 1]. Default is 0.5.
176
+
177
+ activation_mutate_threshold (int): Determines max how much activation mutaiton operation applying. (Function automaticly determines to min) Default: 2
177
178
 
178
- activation_selection_rate (int, optional): If the activation list of a good genome is smaller than this value, only one activation will undergo crossover. This parameter controls model complexity. Default is 2.
179
+ activation_selection_threshold (int, optional): Determines max how much activaton transferable to child from undominant parent. (Function automaticly determines to min) Default: 2
179
180
 
180
181
  dtype (cupy.dtype): Data type for the arrays. Default: cp.float32.
181
182
  Example: cp.float64 or cp.float16 [fp32 for balanced devices, fp64 for strong devices, fp16 for weak devices: not recommended!].
@@ -224,17 +225,14 @@ def evolver(weights,
224
225
  if strategy == 'normal_selective':
225
226
  if bad_genomes_mutation_prob is None: bad_genomes_mutation_prob = 0.7 # EFFECTS MUTATION
226
227
  if bad_genomes_selection_prob is None: bad_genomes_selection_prob = 0.25 # EFFECTS CROSS-OVER
227
- if fitness_bias is None: fitness_bias = 0.5 # The pressure applied by FITNESS to the CROSS-OVER
228
-
228
+
229
229
  elif strategy == 'more_selective':
230
230
  if bad_genomes_mutation_prob is None: bad_genomes_mutation_prob = 0.85 # EFFECTS MUTATION
231
231
  if bad_genomes_selection_prob is None: bad_genomes_selection_prob = 0.1 # EFFECTS CROSS-OVER
232
- if fitness_bias is None: fitness_bias = 0.7 # The pressure applied by FITNESS to the CROSS-OVER
233
232
 
234
233
  elif strategy == 'less_selective':
235
234
  if bad_genomes_mutation_prob is None: bad_genomes_mutation_prob = 0.6 # EFFECTS MUTATION
236
235
  if bad_genomes_selection_prob is None: bad_genomes_selection_prob = 0.5 # EFFECTS CROSS-OVER
237
- if fitness_bias is None: fitness_bias = 0.3 # The pressure applied by FITNESS to the CROSS-OVER
238
236
 
239
237
  else:
240
238
  raise ValueError("strategy parameter must be: 'normal_selective' or 'more_selective' or 'less_selective'")
@@ -251,11 +249,11 @@ def evolver(weights,
251
249
  if fitness_bias < 0 or fitness_bias > 1: raise ValueError("fitness_bias value must be a number between 0 and 1.")
252
250
 
253
251
  if bad_genomes_mutation_prob is not None:
254
- if not isinstance(bad_genomes_mutation_prob, float) or bad_genomes_mutation_prob < 0 or bad_genomes_mutation_prob > 1:
252
+ if bad_genomes_mutation_prob < 0 or bad_genomes_mutation_prob > 1:
255
253
  raise ValueError("bad_genomes_mutation_prob parameter must be float and 0-1 range")
256
254
 
257
255
  if activation_mutate_prob is not None:
258
- if not isinstance(activation_mutate_prob, float) or activation_mutate_prob < 0 or activation_mutate_prob > 1:
256
+ if activation_mutate_prob < 0 or activation_mutate_prob > 1:
259
257
  raise ValueError("activation_mutate_prob parameter must be float and 0-1 range")
260
258
 
261
259
  if len(fitness) % 2 == 0:
@@ -322,7 +320,7 @@ def evolver(weights,
322
320
  cross_over_mode=cross_over_mode,
323
321
  activation_selection_add_prob=activation_selection_add_prob,
324
322
  activation_selection_change_prob=activation_selection_change_prob,
325
- threshold=activation_selection_rate,
323
+ activation_selection_threshold=activation_selection_threshold,
326
324
  bad_genomes_selection_prob=bad_genomes_selection_prob,
327
325
  first_parent_fitness=best_fitness,
328
326
  fitness_bias=fitness_bias,
@@ -351,8 +349,10 @@ def evolver(weights,
351
349
  activation_delete_prob=activation_mutate_delete_prob,
352
350
  activation_change_prob=activation_mutate_change_prob,
353
351
  weight_mutate_prob=weight_mutate_prob,
354
- threshold=weight_mutate_rate,
355
- genome_fitness=normalized_fitness[fitness_index]
352
+ weight_mutate_threshold=weight_mutate_threshold,
353
+ genome_fitness=normalized_fitness[fitness_index],
354
+ activation_mutate_threshold=activation_mutate_threshold,
355
+ epsilon=epsilon
356
356
  )
357
357
 
358
358
  if bar_status: progress.update(1)
@@ -374,17 +374,19 @@ def evolver(weights,
374
374
  print(" POLICY: ", policy)
375
375
  print(" BAD GENOMES MUTATION PROB: ", str(bad_genomes_mutation_prob))
376
376
  print(" GOOD GENOMES MUTATION PROB: ", str(round(1 - bad_genomes_mutation_prob, 2)))
377
+ print(" BAD GENOMES SELECTION PROB: ", str(bad_genomes_selection_prob))
377
378
  print(" WEIGHT MUTATE PROB: ", str(weight_mutate_prob))
378
- print(" WEIGHT MUTATE RATE (THRESHOLD VALUE FOR SINGLE MUTATION): ", str(weight_mutate_rate))
379
+ print(" WEIGHT MUTATE THRESHOLD: ", str(weight_mutate_threshold))
379
380
  print(" ACTIVATION MUTATE PROB: ", str(activation_mutate_prob))
381
+ print(" ACTIVATION MUTATE THRESHOLD: ", str(activation_mutate_threshold))
380
382
  print(" ACTIVATION MUTATE ADD PROB: ", str(activation_mutate_add_prob))
381
383
  print(" ACTIVATION MUTATE DELETE PROB: ", str(activation_mutate_delete_prob))
382
384
  print(" ACTIVATION MUTATE CHANGE PROB: ", str(activation_mutate_change_prob))
385
+ print(" ACTIVATION SELECTION THRESHOLD:", str(activation_selection_threshold))
383
386
  print(" ACTIVATION SELECTION ADD PROB: ", str(activation_selection_add_prob))
384
387
  print(" ACTIVATION SELECTION CHANGE PROB: ", str(activation_selection_change_prob))
385
- print(" FITNESS BIAS: ", str(fitness_bias))
386
- print(" ACTIVATION SELECTION RATE (THRESHOLD VALUE FOR SINGLE CROSS OVER):", str(activation_selection_rate) + '\n')
387
-
388
+ print(" FITNESS BIAS: ", str(fitness_bias) + '\n')
389
+
388
390
  print("*** Performance ***")
389
391
  print(" MAX FITNESS: ", str(cp.round(max(fitness), 2)))
390
392
  print(" MEAN FITNESS: ", str(cp.round(cp.mean(fitness), 2)))
@@ -480,7 +482,7 @@ def cross_over(first_parent_W,
480
482
  cross_over_mode,
481
483
  activation_selection_add_prob,
482
484
  activation_selection_change_prob,
483
- threshold,
485
+ activation_selection_threshold,
484
486
  bad_genomes_selection_prob,
485
487
  first_parent_fitness,
486
488
  second_parent_fitness,
@@ -509,8 +511,7 @@ def cross_over(first_parent_W,
509
511
  activation_selection_change_prob (float): Probability of replacing an activation function in the child genome
510
512
  with one from the second parent.
511
513
 
512
- threshold (float): Determines how quickly activation functions are added or replaced
513
- during the crossover process.
514
+ activation_selection_threshold (int): Determines max how much activaton transferable to child from undominant parent. (Function automaticly determines to min)
514
515
 
515
516
  bad_genomes_selection_prob (float): Probability of selecting a "bad" genome for replacement with the offspring.
516
517
 
@@ -542,7 +543,7 @@ def cross_over(first_parent_W,
542
543
  cross_over_mode='tpm',
543
544
  activation_selection_add_prob=0.8,
544
545
  activation_selection_change_prob=0.5,
545
- threshold=2,
546
+ activation_selection_threshold=2,
546
547
  bad_genomes_selection_prob=0.7,
547
548
  first_parent_fitness=0.9,
548
549
  second_parent_fitness=0.85,
@@ -618,7 +619,7 @@ def cross_over(first_parent_W,
618
619
 
619
620
  if potential_activation_selection_add > activation_selection_add_prob:
620
621
 
621
- threshold = threshold / succes
622
+ threshold = abs(activation_selection_threshold / succes)
622
623
  new_threshold = threshold
623
624
 
624
625
  while True:
@@ -627,9 +628,9 @@ def cross_over(first_parent_W,
627
628
  random_undominant_activation = undominant_parent_act[random_index]
628
629
 
629
630
  child_act.append(random_undominant_activation)
631
+ new_threshold += threshold
630
632
 
631
633
  if len(dominant_parent_act) > new_threshold:
632
- new_threshold += threshold
633
634
  pass
634
635
 
635
636
  else:
@@ -640,7 +641,7 @@ def cross_over(first_parent_W,
640
641
 
641
642
  if potential_activation_selection_change_prob > activation_selection_change_prob:
642
643
 
643
- threshold = threshold / succes
644
+ threshold = abs(activation_selection_threshold / succes)
644
645
  new_threshold = threshold
645
646
 
646
647
  while True:
@@ -650,9 +651,9 @@ def cross_over(first_parent_W,
650
651
  random_undominant_activation = undominant_parent_act[random_index_undominant]
651
652
 
652
653
  child_act[random_index_dominant] = random_undominant_activation
654
+ new_threshold += threshold
653
655
 
654
656
  if len(dominant_parent_act) > new_threshold:
655
- new_threshold += threshold
656
657
  pass
657
658
 
658
659
  else:
@@ -668,8 +669,10 @@ def mutation(weight,
668
669
  activation_delete_prob,
669
670
  activation_change_prob,
670
671
  weight_mutate_prob,
671
- threshold,
672
- genome_fitness):
672
+ weight_mutate_threshold,
673
+ genome_fitness,
674
+ activation_mutate_threshold,
675
+ epsilon):
673
676
  """
674
677
  Performs mutation on the given weight matrix and activation functions.
675
678
  - The weight matrix is mutated by randomly changing its values based on the mutation probability.
@@ -690,10 +693,13 @@ def mutation(weight,
690
693
 
691
694
  weight_mutate_prob (float): The probability of mutating weight matrix.
692
695
 
693
- threshold (float): If the value you enter here is equal to the result of input layer * output layer, only a single weight will be mutated during each mutation process. If the value you enter here is half of the result of input layer * output layer, two weights in the weight matrix will be mutated.
696
+ weight_mutate_threshold (float): Determines max how much weight mutaiton operation applying. (Function automaticly determines to min)
694
697
 
695
698
  genome_fitness (float): Fitness value of genome
696
699
 
700
+ activation_mutate_threshold (float): Determines max how much activation mutaiton operation applying. (Function automaticly determines to min)
701
+
702
+ epsilon (float): Small epsilon constant
697
703
 
698
704
  Returns:
699
705
  tuple: A tuple containing:
@@ -725,7 +731,7 @@ def mutation(weight,
725
731
 
726
732
  max_threshold = row_end * col_end
727
733
 
728
- threshold = threshold * genome_fitness
734
+ threshold = weight_mutate_threshold * genome_fitness
729
735
  new_threshold = threshold
730
736
 
731
737
  for _ in range(max_threshold):
@@ -734,56 +740,71 @@ def mutation(weight,
734
740
  selected_col = int(random.uniform(start, col_end))
735
741
 
736
742
  weight[selected_row, selected_col] = random.uniform(-1, 1)
743
+ new_threshold += threshold
737
744
 
738
745
  if max_threshold > new_threshold:
739
- new_threshold += threshold
746
+ pass
740
747
 
741
748
  else:
742
749
  break
743
-
744
- activation_mutate_prob = 1 - activation_mutate_prob
745
- potential_activation_mutation = random.uniform(0, 1)
746
750
 
747
- if potential_activation_mutation > activation_mutate_prob:
748
-
749
- except_this = ['spiral', 'circular']
750
- all_acts = [item for item in all_activations() if item not in except_this] # SPIRAL AND CIRCULAR ACTIVATION DISCARDED
751
-
752
- activation_add_prob = 1 - activation_add_prob
753
- activation_delete_prob = 1 - activation_delete_prob
754
- activation_change_prob = 1 - activation_change_prob
751
+ activation_mutate_prob = 1 - activation_mutate_prob
752
+ potential_activation_mutation = random.uniform(0, 1)
755
753
 
756
- potential_activation_add_prob = random.uniform(0, 1)
757
- potential_activation_delete_prob = random.uniform(0, 1)
758
- potential_activation_change_prob = random.uniform(0, 1)
754
+ if potential_activation_mutation > activation_mutate_prob:
755
+
756
+ genome_fitness += epsilon
757
+ threshold = abs(activation_mutate_threshold / genome_fitness)
758
+ max_threshold = len(activations)
759
759
 
760
- if potential_activation_add_prob > activation_add_prob:
760
+ new_threshold = threshold
761
761
 
762
- try:
763
-
764
- random_index_all_act = int(random.uniform(0, len(all_acts)-1))
765
- activations.append(all_acts[random_index_all_act])
762
+ except_this = ['spiral', 'circular']
763
+ all_acts = [item for item in all_activations() if item not in except_this] # SPIRAL AND CIRCULAR ACTIVATION DISCARDED
764
+
765
+ activation_add_prob = 1 - activation_add_prob
766
+ activation_delete_prob = 1 - activation_delete_prob
767
+ activation_change_prob = 1 - activation_change_prob
766
768
 
767
- except:
769
+ for _ in range(max_threshold):
768
770
 
769
- activation = activations
770
- activations = []
771
+ potential_activation_add_prob = random.uniform(0, 1)
772
+ potential_activation_delete_prob = random.uniform(0, 1)
773
+ potential_activation_change_prob = random.uniform(0, 1)
771
774
 
772
- activations.append(activation)
773
- activations.append(all_acts[int(random.uniform(0, len(all_acts)-1))])
774
775
 
775
- if potential_activation_delete_prob > activation_delete_prob and len(activations) > 1:
776
-
777
- random_index = random.randint(0, len(activations) - 1)
778
- activations.pop(random_index)
779
-
780
-
781
- if potential_activation_change_prob > activation_change_prob:
782
-
783
- random_index_all_act = int(random.uniform(0, len(all_acts)-1))
784
- random_index_genom_act = int(random.uniform(0, len(activations)-1))
776
+ if potential_activation_delete_prob > activation_delete_prob and len(activations) > 1:
777
+
778
+ random_index = random.randint(0, len(activations) - 1)
779
+ activations.pop(random_index)
780
+
781
+
782
+ if potential_activation_add_prob > activation_add_prob:
783
+
784
+ try:
785
+
786
+ random_index_all_act = int(random.uniform(0, len(all_acts)-1))
787
+ activations.append(all_acts[random_index_all_act])
788
+
789
+ except:
790
+
791
+ activation = activations
792
+ activations = []
793
+
794
+ activations.append(activation)
795
+ activations.append(all_acts[int(random.uniform(0, len(all_acts)-1))])
796
+
797
+ if potential_activation_change_prob > activation_change_prob:
798
+
799
+ random_index_all_act = int(random.uniform(0, len(all_acts)-1))
800
+ random_index_genom_act = int(random.uniform(0, len(activations)-1))
801
+
802
+ activations[random_index_genom_act] = all_acts[random_index_all_act]
803
+
804
+ new_threshold += threshold
785
805
 
786
- activations[random_index_genom_act] = all_acts[random_index_all_act]
806
+ if max_threshold > new_threshold: pass
807
+ else: break
787
808
 
788
809
  return weight, activations
789
810
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.2.6b8
3
+ Version: 4.2.7
4
4
  Summary: PyerualJetwork is a machine learning library supported with GPU(CUDA) acceleration written in Python for professionals and researchers including with PLAN algorithm, PLANEAT algorithm (genetic optimization). Also includes data pre-process and memory manegament
5
5
  Author: Hasan Can Beydili
6
6
  Author-email: tchasancan@gmail.com
@@ -1,4 +1,4 @@
1
- pyerualjetwork/__init__.py,sha256=YWqrIcXhOQjha7hQXj1uWc-ZjE13OkHcsVXv3_-IGX4,641
1
+ pyerualjetwork/__init__.py,sha256=QoWVlKx1oD7DDQipA1e4Sgk-kgmbFt5TqDTB3vFXiRs,639
2
2
  pyerualjetwork/activation_functions.py,sha256=WWOdMd5pI6ZKe-ieKCIsKAYPQODHuXYxx7tzhA5xjes,11767
3
3
  pyerualjetwork/activation_functions_cuda.py,sha256=KmXJ5Cdig46XAMYakXFPEOlxSxtFJjD21-i3nGtxPjE,11807
4
4
  pyerualjetwork/data_operations.py,sha256=pb5CqJ0Th6fCjTNMCtqQMiwH3KezTxAijacglsKUxmY,14730
@@ -13,12 +13,12 @@ pyerualjetwork/model_operations.py,sha256=RKqnh7-MByFosxqme4q4jC1lOndX26O-OVXYV6
13
13
  pyerualjetwork/model_operations_cuda.py,sha256=XnKKq54ZLaqCm-NaJ6d8IToACKcKg2Ttq6moowVRRWo,13365
14
14
  pyerualjetwork/plan.py,sha256=UzCTFCA9cTv9ITCtsqfJ1g02rCMyescoIV6j1amvYGw,32134
15
15
  pyerualjetwork/plan_cuda.py,sha256=hpXZl3h7B1qAVYW-gZebwKMZd4-ftAZ-u05teOJjsno,33525
16
- pyerualjetwork/planeat.py,sha256=cDr0QfOD4FFibcpgsnyQiSpRUwkfYHkBJGqxBnyzx9Q,38893
17
- pyerualjetwork/planeat_cuda.py,sha256=uwbEU_GG3TSaIYUhaU8k13n3bSwFDhCWug4kSLvOHb4,38846
16
+ pyerualjetwork/planeat.py,sha256=9W1QTEw7TbDuGWvFbFCPeCZ2SmooeL8wjtn2cCjVr6Y,39440
17
+ pyerualjetwork/planeat_cuda.py,sha256=lnCvyyDVhs4pybeVzmQBOf1H1_fqmwXZwZNDrLQEAcA,39499
18
18
  pyerualjetwork/ui.py,sha256=wu2BhU1k-w3Kcho5Jtq4SEKe68ftaUeRGneUOSCVDjU,575
19
19
  pyerualjetwork/visualizations.py,sha256=1SKMZaJ80OD2qHUyMxW1IOv8zwmxzMPxclfbeq1Xr4g,28772
20
20
  pyerualjetwork/visualizations_cuda.py,sha256=KbMhfsLlxujy_i3QrwCf734Q-k6d7Zn_7CEbm3gzK9w,29186
21
- pyerualjetwork-4.2.6b8.dist-info/METADATA,sha256=y-mt0kx3VmyrZE-0FYe3VOlHSTL0qweaLW2moncD0A0,7454
22
- pyerualjetwork-4.2.6b8.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
- pyerualjetwork-4.2.6b8.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
- pyerualjetwork-4.2.6b8.dist-info/RECORD,,
21
+ pyerualjetwork-4.2.7.dist-info/METADATA,sha256=uhb0FLFa5h8P5nM10tZNC3cAFKxtjVqxC_WLygaBiMw,7452
22
+ pyerualjetwork-4.2.7.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
+ pyerualjetwork-4.2.7.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
+ pyerualjetwork-4.2.7.dist-info/RECORD,,