pyerualjetwork 4.2.7b0__py3-none-any.whl → 4.2.7b2__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.7b0"
1
+ __version__ = "4.2.7b2"
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,
84
+ bad_genomes_mutation_prob=None,
86
85
  fitness_bias=None,
87
- cross_over_mode='tpm',
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,
89
+ activation_mutate_change_prob=0.5,
90
+ activation_selection_add_prob=0.5,
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,
91
96
  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,
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.
@@ -145,7 +146,7 @@ def evolver(weights,
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.
@@ -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:
@@ -250,11 +251,11 @@ def evolver(weights,
250
251
  if fitness_bias < 0 or fitness_bias > 1: raise ValueError("fitness_bias value must be a number between 0 and 1.")
251
252
 
252
253
  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:
254
+ if bad_genomes_mutation_prob < 0 or bad_genomes_mutation_prob > 1:
254
255
  raise ValueError("bad_genomes_mutation_prob parameter must be float and 0-1 range")
255
256
 
256
257
  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:
258
+ if activation_mutate_prob < 0 or activation_mutate_prob > 1:
258
259
  raise ValueError("activation_mutate_prob parameter must be float and 0-1 range")
259
260
 
260
261
  if len(fitness) % 2 == 0:
@@ -321,7 +322,7 @@ def evolver(weights,
321
322
  cross_over_mode=cross_over_mode,
322
323
  activation_selection_add_prob=activation_selection_add_prob,
323
324
  activation_selection_change_prob=activation_selection_change_prob,
324
- threshold=activation_selection_rate,
325
+ activation_selection_threshold=activation_selection_threshold,
325
326
  bad_genomes_selection_prob=bad_genomes_selection_prob,
326
327
  first_parent_fitness=best_fitness,
327
328
  fitness_bias=fitness_bias,
@@ -350,8 +351,10 @@ def evolver(weights,
350
351
  activation_delete_prob=activation_mutate_delete_prob,
351
352
  activation_change_prob=activation_mutate_change_prob,
352
353
  weight_mutate_prob=weight_mutate_prob,
353
- threshold=weight_mutate_rate,
354
- genome_fitness=normalized_fitness[fitness_index]
354
+ weight_mutate_threshold=weight_mutate_threshold,
355
+ genome_fitness=normalized_fitness[fitness_index],
356
+ activation_mutate_threshold=activation_mutate_threshold,
357
+ epsilon=epsilon
355
358
  )
356
359
 
357
360
  if bar_status: progress.update(1)
@@ -375,15 +378,16 @@ def evolver(weights,
375
378
  print(" GOOD GENOMES MUTATION PROB: ", str(round(1 - bad_genomes_mutation_prob, 2)))
376
379
  print(" BAD GENOMES SELECTION PROB: ", str(bad_genomes_selection_prob))
377
380
  print(" WEIGHT MUTATE PROB: ", str(weight_mutate_prob))
378
- print(" WEIGHT MUTATE RATE (THRESHOLD VALUE FOR SINGLE MUTATION): ", str(weight_mutate_rate))
381
+ print(" WEIGHT MUTATE THRESHOLD: ", str(weight_mutate_threshold))
379
382
  print(" ACTIVATION MUTATE PROB: ", str(activation_mutate_prob))
383
+ print(" ACTIVATION MUTATE THRESHOLD: ", str(activation_mutate_threshold))
380
384
  print(" ACTIVATION MUTATE ADD PROB: ", str(activation_mutate_add_prob))
381
385
  print(" ACTIVATION MUTATE DELETE PROB: ", str(activation_mutate_delete_prob))
382
386
  print(" ACTIVATION MUTATE CHANGE PROB: ", str(activation_mutate_change_prob))
387
+ print(" ACTIVATION SELECTION THRESHOLD:", str(activation_selection_threshold))
383
388
  print(" ACTIVATION SELECTION ADD PROB: ", str(activation_selection_add_prob))
384
389
  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')
390
+ print(" FITNESS BIAS: ", str(fitness_bias) + '\n')
387
391
 
388
392
 
389
393
  print("*** Performance ***")
@@ -477,7 +481,7 @@ def cross_over(first_parent_W,
477
481
  cross_over_mode,
478
482
  activation_selection_add_prob,
479
483
  activation_selection_change_prob,
480
- threshold,
484
+ activation_selection_threshold,
481
485
  bad_genomes_selection_prob,
482
486
  first_parent_fitness,
483
487
  second_parent_fitness,
@@ -506,8 +510,7 @@ def cross_over(first_parent_W,
506
510
  activation_selection_change_prob (float): Probability of replacing an activation function in the child genome
507
511
  with one from the second parent.
508
512
 
509
- threshold (float): Determines how quickly activation functions are added or replaced
510
- during the crossover process.
513
+ activation_selection_threshold (float): (float): Determines max how much activaton transferable to child from undominant parent. (Function automaticly determines to min)
511
514
 
512
515
  bad_genomes_selection_prob (float): Probability of selecting a "bad" genome for replacement with the offspring.
513
516
 
@@ -539,7 +542,7 @@ def cross_over(first_parent_W,
539
542
  cross_over_mode='tpm',
540
543
  activation_selection_add_prob=0.8,
541
544
  activation_selection_change_prob=0.5,
542
- threshold=2,
545
+ activation_selection_threshold=2,
543
546
  bad_genomes_selection_prob=0.7,
544
547
  first_parent_fitness=0.9,
545
548
  second_parent_fitness=0.85,
@@ -614,7 +617,7 @@ def cross_over(first_parent_W,
614
617
 
615
618
  if potential_activation_selection_add > activation_selection_add_prob:
616
619
 
617
- threshold = abs(threshold / succes)
620
+ threshold = abs(activation_selection_threshold / succes)
618
621
  new_threshold = threshold
619
622
 
620
623
  while True:
@@ -661,9 +664,10 @@ def mutation(weight,
661
664
  activation_delete_prob,
662
665
  activation_change_prob,
663
666
  weight_mutate_prob,
664
- threshold,
665
- genome_fitness
666
- ):
667
+ weight_mutate_threshold,
668
+ genome_fitness,
669
+ activation_mutate_threshold,
670
+ epsilon):
667
671
  """
668
672
  Performs mutation on the given weight matrix and activation functions.
669
673
  - The weight matrix is mutated by randomly changing its values based on the mutation probability.
@@ -684,9 +688,13 @@ def mutation(weight,
684
688
 
685
689
  weight_mutate_prob (float): The probability of mutating weight matrix.
686
690
 
687
- 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.
691
+ weight_mutate_threshold (float): Determines max how much weight mutaiton operation applying. (Function automaticly determines to min)
688
692
 
689
- genome_fitness (float): Fitness value of genome
693
+ genome_fitness (float): Fitness (0-1) value of genome
694
+
695
+ activation_mutate_threshold (float): Determines max how much activation mutaiton operation applying. (Function automaticly determines to min)
696
+
697
+ epsilon (float): Small epsilon constant
690
698
 
691
699
  Returns:
692
700
  tuple: A tuple containing:
@@ -718,7 +726,7 @@ def mutation(weight,
718
726
 
719
727
  max_threshold = row_end * col_end
720
728
 
721
- threshold = threshold * genome_fitness
729
+ threshold = weight_mutate_threshold * genome_fitness
722
730
  new_threshold = threshold
723
731
 
724
732
  for _ in range(max_threshold):
@@ -735,50 +743,64 @@ def mutation(weight,
735
743
  else:
736
744
  break
737
745
 
738
-
739
- activation_mutate_prob = 1 - activation_mutate_prob
740
- potential_activation_mutation = random.uniform(0, 1)
746
+ activation_mutate_prob = 1 - activation_mutate_prob
747
+ potential_activation_mutation = random.uniform(0, 1)
741
748
 
742
- if potential_activation_mutation > activation_mutate_prob:
743
-
744
- except_this = ['spiral', 'circular']
745
- all_acts = [item for item in all_activations() if item not in except_this] # SPIRAL AND CIRCULAR ACTIVATION DISCARDED
746
-
747
- activation_add_prob = 1 - activation_add_prob
748
- activation_delete_prob = 1 - activation_delete_prob
749
- activation_change_prob = 1 - activation_change_prob
749
+ if potential_activation_mutation > activation_mutate_prob:
750
+
751
+ genome_fitness += epsilon
752
+ threshold = abs(activation_mutate_threshold / genome_fitness)
753
+ max_threshold = len(activations)
750
754
 
751
- potential_activation_add_prob = random.uniform(0, 1)
752
- potential_activation_delete_prob = random.uniform(0, 1)
753
- potential_activation_change_prob = random.uniform(0, 1)
755
+ new_threshold = threshold
754
756
 
755
- if potential_activation_add_prob > activation_add_prob:
757
+ except_this = ['spiral', 'circular']
758
+ all_acts = [item for item in all_activations() if item not in except_this] # SPIRAL AND CIRCULAR ACTIVATION DISCARDED
759
+
760
+ activation_add_prob = 1 - activation_add_prob
761
+ activation_delete_prob = 1 - activation_delete_prob
762
+ activation_change_prob = 1 - activation_change_prob
756
763
 
757
- try:
758
-
759
- random_index_all_act = int(random.uniform(0, len(all_acts)-1))
760
- activations.append(all_acts[random_index_all_act])
764
+ for _ in range(max_threshold):
761
765
 
762
- except:
766
+ potential_activation_add_prob = random.uniform(0, 1)
767
+ potential_activation_delete_prob = random.uniform(0, 1)
768
+ potential_activation_change_prob = random.uniform(0, 1)
763
769
 
764
- activation = activations
765
- activations = []
766
770
 
767
- activations.append(activation)
768
- activations.append(all_acts[int(random.uniform(0, len(all_acts)-1))])
769
-
770
- if potential_activation_delete_prob > activation_delete_prob and len(activations) > 1:
771
-
772
- random_index = random.randint(0, len(activations) - 1)
773
- activations.pop(random_index)
774
-
775
-
776
- if potential_activation_change_prob > activation_change_prob:
777
-
778
- random_index_all_act = int(random.uniform(0, len(all_acts)-1))
779
- random_index_genom_act = int(random.uniform(0, len(activations)-1))
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_add_prob > activation_add_prob:
778
+
779
+ try:
780
+
781
+ random_index_all_act = int(random.uniform(0, len(all_acts)-1))
782
+ activations.append(all_acts[random_index_all_act])
783
+
784
+ except:
785
+
786
+ activation = activations
787
+ activations = []
788
+
789
+ activations.append(activation)
790
+ activations.append(all_acts[int(random.uniform(0, len(all_acts)-1))])
791
+
792
+
793
+ if potential_activation_change_prob > activation_change_prob:
794
+
795
+ random_index_all_act = int(random.uniform(0, len(all_acts)-1))
796
+ random_index_genom_act = int(random.uniform(0, len(activations)-1))
797
+
798
+ activations[random_index_genom_act] = all_acts[random_index_all_act]
799
+
800
+ new_threshold += threshold
780
801
 
781
- activations[random_index_genom_act] = all_acts[random_index_all_act]
802
+ if max_threshold > new_threshold: pass
803
+ else: break
782
804
 
783
805
  return weight, activations
784
806
 
@@ -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,
86
+ bad_genomes_mutation_prob=None,
88
87
  fitness_bias=None,
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.5,
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.
@@ -165,17 +166,17 @@ def evolver(weights,
165
166
  weight_mutate_prob (float, optional): The probability of mutating a weight in the genome.
166
167
  Must be in the range [0, 1]. Default is 1.
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!].
@@ -251,11 +252,11 @@ def evolver(weights,
251
252
  if fitness_bias < 0 or fitness_bias > 1: raise ValueError("fitness_bias value must be a number between 0 and 1.")
252
253
 
253
254
  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:
255
+ if bad_genomes_mutation_prob < 0 or bad_genomes_mutation_prob > 1:
255
256
  raise ValueError("bad_genomes_mutation_prob parameter must be float and 0-1 range")
256
257
 
257
258
  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:
259
+ if activation_mutate_prob < 0 or activation_mutate_prob > 1:
259
260
  raise ValueError("activation_mutate_prob parameter must be float and 0-1 range")
260
261
 
261
262
  if len(fitness) % 2 == 0:
@@ -322,7 +323,7 @@ def evolver(weights,
322
323
  cross_over_mode=cross_over_mode,
323
324
  activation_selection_add_prob=activation_selection_add_prob,
324
325
  activation_selection_change_prob=activation_selection_change_prob,
325
- threshold=activation_selection_rate,
326
+ activation_selection_threshold=activation_selection_threshold,
326
327
  bad_genomes_selection_prob=bad_genomes_selection_prob,
327
328
  first_parent_fitness=best_fitness,
328
329
  fitness_bias=fitness_bias,
@@ -351,8 +352,10 @@ def evolver(weights,
351
352
  activation_delete_prob=activation_mutate_delete_prob,
352
353
  activation_change_prob=activation_mutate_change_prob,
353
354
  weight_mutate_prob=weight_mutate_prob,
354
- threshold=weight_mutate_rate,
355
- genome_fitness=normalized_fitness[fitness_index]
355
+ weight_mutate_threshold=weight_mutate_threshold,
356
+ genome_fitness=normalized_fitness[fitness_index],
357
+ activation_mutate_threshold=activation_mutate_threshold,
358
+ epsilon=epsilon
356
359
  )
357
360
 
358
361
  if bar_status: progress.update(1)
@@ -374,17 +377,19 @@ def evolver(weights,
374
377
  print(" POLICY: ", policy)
375
378
  print(" BAD GENOMES MUTATION PROB: ", str(bad_genomes_mutation_prob))
376
379
  print(" GOOD GENOMES MUTATION PROB: ", str(round(1 - bad_genomes_mutation_prob, 2)))
380
+ print(" BAD GENOMES SELECTION PROB: ", str(bad_genomes_selection_prob))
377
381
  print(" WEIGHT MUTATE PROB: ", str(weight_mutate_prob))
378
- print(" WEIGHT MUTATE RATE (THRESHOLD VALUE FOR SINGLE MUTATION): ", str(weight_mutate_rate))
382
+ print(" WEIGHT MUTATE THRESHOLD: ", str(weight_mutate_threshold))
379
383
  print(" ACTIVATION MUTATE PROB: ", str(activation_mutate_prob))
384
+ print(" ACTIVATION MUTATE THRESHOLD: ", str(activation_mutate_threshold))
380
385
  print(" ACTIVATION MUTATE ADD PROB: ", str(activation_mutate_add_prob))
381
386
  print(" ACTIVATION MUTATE DELETE PROB: ", str(activation_mutate_delete_prob))
382
387
  print(" ACTIVATION MUTATE CHANGE PROB: ", str(activation_mutate_change_prob))
388
+ print(" ACTIVATION SELECTION THRESHOLD:", str(activation_selection_threshold))
383
389
  print(" ACTIVATION SELECTION ADD PROB: ", str(activation_selection_add_prob))
384
390
  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
-
391
+ print(" FITNESS BIAS: ", str(fitness_bias) + '\n')
392
+
388
393
  print("*** Performance ***")
389
394
  print(" MAX FITNESS: ", str(cp.round(max(fitness), 2)))
390
395
  print(" MEAN FITNESS: ", str(cp.round(cp.mean(fitness), 2)))
@@ -480,7 +485,7 @@ def cross_over(first_parent_W,
480
485
  cross_over_mode,
481
486
  activation_selection_add_prob,
482
487
  activation_selection_change_prob,
483
- threshold,
488
+ activation_selection_threshold,
484
489
  bad_genomes_selection_prob,
485
490
  first_parent_fitness,
486
491
  second_parent_fitness,
@@ -509,8 +514,7 @@ def cross_over(first_parent_W,
509
514
  activation_selection_change_prob (float): Probability of replacing an activation function in the child genome
510
515
  with one from the second parent.
511
516
 
512
- threshold (float): Determines how quickly activation functions are added or replaced
513
- during the crossover process.
517
+ activation_selection_threshold (int): Determines max how much activaton transferable to child from undominant parent. (Function automaticly determines to min)
514
518
 
515
519
  bad_genomes_selection_prob (float): Probability of selecting a "bad" genome for replacement with the offspring.
516
520
 
@@ -542,7 +546,7 @@ def cross_over(first_parent_W,
542
546
  cross_over_mode='tpm',
543
547
  activation_selection_add_prob=0.8,
544
548
  activation_selection_change_prob=0.5,
545
- threshold=2,
549
+ activation_selection_threshold=2,
546
550
  bad_genomes_selection_prob=0.7,
547
551
  first_parent_fitness=0.9,
548
552
  second_parent_fitness=0.85,
@@ -618,7 +622,7 @@ def cross_over(first_parent_W,
618
622
 
619
623
  if potential_activation_selection_add > activation_selection_add_prob:
620
624
 
621
- threshold = abs(threshold / succes)
625
+ threshold = abs(activation_selection_threshold / succes)
622
626
  new_threshold = threshold
623
627
 
624
628
  while True:
@@ -668,8 +672,10 @@ def mutation(weight,
668
672
  activation_delete_prob,
669
673
  activation_change_prob,
670
674
  weight_mutate_prob,
671
- threshold,
672
- genome_fitness):
675
+ weight_mutate_threshold,
676
+ genome_fitness,
677
+ activation_mutate_threshold,
678
+ epsilon):
673
679
  """
674
680
  Performs mutation on the given weight matrix and activation functions.
675
681
  - The weight matrix is mutated by randomly changing its values based on the mutation probability.
@@ -690,10 +696,13 @@ def mutation(weight,
690
696
 
691
697
  weight_mutate_prob (float): The probability of mutating weight matrix.
692
698
 
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.
699
+ weight_mutate_threshold (float): Determines max how much weight mutaiton operation applying. (Function automaticly determines to min)
694
700
 
695
701
  genome_fitness (float): Fitness value of genome
696
702
 
703
+ activation_mutate_threshold (float): Determines max how much activation mutaiton operation applying. (Function automaticly determines to min)
704
+
705
+ epsilon (float): Small epsilon constant
697
706
 
698
707
  Returns:
699
708
  tuple: A tuple containing:
@@ -725,7 +734,7 @@ def mutation(weight,
725
734
 
726
735
  max_threshold = row_end * col_end
727
736
 
728
- threshold = threshold * genome_fitness
737
+ threshold = weight_mutate_threshold * genome_fitness
729
738
  new_threshold = threshold
730
739
 
731
740
  for _ in range(max_threshold):
@@ -741,50 +750,64 @@ def mutation(weight,
741
750
 
742
751
  else:
743
752
  break
744
-
745
- activation_mutate_prob = 1 - activation_mutate_prob
746
- potential_activation_mutation = random.uniform(0, 1)
747
753
 
748
- if potential_activation_mutation > activation_mutate_prob:
749
-
750
- except_this = ['spiral', 'circular']
751
- all_acts = [item for item in all_activations() if item not in except_this] # SPIRAL AND CIRCULAR ACTIVATION DISCARDED
752
-
753
- activation_add_prob = 1 - activation_add_prob
754
- activation_delete_prob = 1 - activation_delete_prob
755
- activation_change_prob = 1 - activation_change_prob
754
+ activation_mutate_prob = 1 - activation_mutate_prob
755
+ potential_activation_mutation = random.uniform(0, 1)
756
756
 
757
- potential_activation_add_prob = random.uniform(0, 1)
758
- potential_activation_delete_prob = random.uniform(0, 1)
759
- potential_activation_change_prob = random.uniform(0, 1)
757
+ if potential_activation_mutation > activation_mutate_prob:
758
+
759
+ genome_fitness += epsilon
760
+ threshold = abs(activation_mutate_threshold / genome_fitness)
761
+ max_threshold = len(activations)
760
762
 
761
- if potential_activation_add_prob > activation_add_prob:
763
+ new_threshold = threshold
762
764
 
763
- try:
764
-
765
- random_index_all_act = int(random.uniform(0, len(all_acts)-1))
766
- activations.append(all_acts[random_index_all_act])
765
+ except_this = ['spiral', 'circular']
766
+ all_acts = [item for item in all_activations() if item not in except_this] # SPIRAL AND CIRCULAR ACTIVATION DISCARDED
767
+
768
+ activation_add_prob = 1 - activation_add_prob
769
+ activation_delete_prob = 1 - activation_delete_prob
770
+ activation_change_prob = 1 - activation_change_prob
767
771
 
768
- except:
772
+ for _ in range(max_threshold):
769
773
 
770
- activation = activations
771
- activations = []
774
+ potential_activation_add_prob = random.uniform(0, 1)
775
+ potential_activation_delete_prob = random.uniform(0, 1)
776
+ potential_activation_change_prob = random.uniform(0, 1)
772
777
 
773
- activations.append(activation)
774
- activations.append(all_acts[int(random.uniform(0, len(all_acts)-1))])
775
778
 
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_change_prob > activation_change_prob:
783
-
784
- random_index_all_act = int(random.uniform(0, len(all_acts)-1))
785
- random_index_genom_act = int(random.uniform(0, len(activations)-1))
779
+ if potential_activation_delete_prob > activation_delete_prob and len(activations) > 1:
780
+
781
+ random_index = random.randint(0, len(activations) - 1)
782
+ activations.pop(random_index)
783
+
784
+
785
+ if potential_activation_add_prob > activation_add_prob:
786
+
787
+ try:
788
+
789
+ random_index_all_act = int(random.uniform(0, len(all_acts)-1))
790
+ activations.append(all_acts[random_index_all_act])
791
+
792
+ except:
793
+
794
+ activation = activations
795
+ activations = []
796
+
797
+ activations.append(activation)
798
+ activations.append(all_acts[int(random.uniform(0, len(all_acts)-1))])
799
+
800
+ if potential_activation_change_prob > activation_change_prob:
801
+
802
+ random_index_all_act = int(random.uniform(0, len(all_acts)-1))
803
+ random_index_genom_act = int(random.uniform(0, len(activations)-1))
804
+
805
+ activations[random_index_genom_act] = all_acts[random_index_all_act]
806
+
807
+ new_threshold += threshold
786
808
 
787
- activations[random_index_genom_act] = all_acts[random_index_all_act]
809
+ if max_threshold > new_threshold: pass
810
+ else: break
788
811
 
789
812
  return weight, activations
790
813
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.2.7b0
3
+ Version: 4.2.7b2
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=ATsdY6XagZY8d3RYpOmbFb_FXtIG2nPE8V_KgIBAeDs,641
1
+ pyerualjetwork/__init__.py,sha256=R2t2Y9xGH2tGKw-ccl-sjVrHEqYcvp0timRkvKZCbxE,641
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=3zCCtrPPs1zxysL73uMdEjYAFcDyJwDtT7y6Jvu4iLk,38872
17
- pyerualjetwork/planeat_cuda.py,sha256=3y-fC79rRdPa27HwzxUzlBN8y9j--1DezOv7SowVvgM,38865
16
+ pyerualjetwork/planeat.py,sha256=7mWEXHZouy_SfwAnHR2vl3SdHhz4sFnELOGCFhVDm8M,39765
17
+ pyerualjetwork/planeat_cuda.py,sha256=bONKAMZigjuNDZc4mIPxwb9QHZ2oazWE9YS3KxE_JZA,39815
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.7b0.dist-info/METADATA,sha256=dICXjXgUm_nrIuFQk45yD0x4JbFfokscOM17gN0_y30,7454
22
- pyerualjetwork-4.2.7b0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
- pyerualjetwork-4.2.7b0.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
- pyerualjetwork-4.2.7b0.dist-info/RECORD,,
21
+ pyerualjetwork-4.2.7b2.dist-info/METADATA,sha256=3-7MhsbqNwShG37tZ-6Ye45krXF_UW1qWcjWubss-Ig,7454
22
+ pyerualjetwork-4.2.7b2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
+ pyerualjetwork-4.2.7b2.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
+ pyerualjetwork-4.2.7b2.dist-info/RECORD,,