pyerualjetwork 4.2.3__py3-none-any.whl → 4.2.4__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.3"
1
+ __version__ = "4.2.4"
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,10 +81,9 @@ def evolver(weights,
81
81
  bar_status=True,
82
82
  strategy='normal_selective',
83
83
  target_fitness='max',
84
- mutations=True,
85
84
  bad_genomes_mutation_prob=None,
86
85
  activation_mutate_prob=0.5,
87
- save_best_genom=True,
86
+ save_best_genome=True,
88
87
  fitness_bias=None,
89
88
  cross_over_mode='tpm',
90
89
  activation_mutate_add_prob=0.5,
@@ -143,9 +142,6 @@ def evolver(weights,
143
142
  target_fitness (str, optional): Target fitness strategy for PLANEAT optimization. ('max' maximizes fitness, 'min' minimizes fitness.) Default: 'max'.
144
143
 
145
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: Determined by the `strategy`.
146
-
147
- mutations (bool, optional): If True, mutations are applied to the bad genomes and potentially
148
- to the best genomes as well. Default is True.
149
145
 
150
146
  bad_genomes_mutation_prob (float, optional): The probability of applying mutation to the bad genomes.
151
147
  Must be in the range [0, 1]. Also affects the mutation probability of the best genomes inversely.
@@ -305,6 +301,12 @@ def evolver(weights,
305
301
  best_fitness = normalized_fitness[-1]
306
302
  epsilon = np.finfo(float).eps
307
303
 
304
+ child_W = np.copy(bad_weights)
305
+ child_act = bad_activations.copy()
306
+
307
+ mutated_W = np.copy(bad_weights)
308
+ mutated_act = bad_activations.copy()
309
+
308
310
  for i in range(len(bad_weights)):
309
311
 
310
312
  if policy == 'aggressive':
@@ -319,7 +321,7 @@ def evolver(weights,
319
321
 
320
322
  second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
321
323
 
322
- bad_weights[i], bad_activations[i] = cross_over(first_parent_W,
324
+ child_W[i], child_act[i] = cross_over(first_parent_W,
323
325
  second_parent_W,
324
326
  first_parent_act,
325
327
  second_parent_act,
@@ -333,41 +335,40 @@ def evolver(weights,
333
335
  second_parent_fitness=normalized_fitness[s_i],
334
336
  epsilon=epsilon
335
337
  )
336
-
337
-
338
- if mutations is True:
339
- mutation_prob = random.uniform(0, 1)
340
-
341
- if mutation_prob > bad_genomes_mutation_prob:
342
- if (save_best_genom == True and not np.array_equal(good_weights[i], best_weight)) or save_best_genom == False:
343
-
344
- good_weights[i], good_activations[i] = mutation(good_weights[i],
345
- good_activations[i],
346
- activation_mutate_prob=activation_mutate_prob,
347
- activation_add_prob=activation_mutate_add_prob,
348
- activation_delete_prob=activation_mutate_delete_prob,
349
- activation_change_prob=activation_mutate_change_prob,
350
- weight_mutate_prob=weight_mutate_prob,
351
- threshold=weight_mutate_rate,
352
- genome_fitness=normalized_fitness[i]
353
- )
354
-
355
- elif mutation_prob < bad_genomes_mutation_prob:
356
- bad_weights[i], bad_activations[i] = mutation(bad_weights[i],
357
- bad_activations[i],
358
- activation_mutate_prob=activation_mutate_prob,
359
- activation_add_prob=activation_mutate_add_prob,
360
- activation_delete_prob=activation_mutate_delete_prob,
361
- activation_change_prob=activation_mutate_change_prob,
362
- weight_mutate_prob=weight_mutate_prob,
363
- threshold=weight_mutate_rate,
364
- genome_fitness=normalized_fitness[i]
365
- )
338
+
339
+ mutation_prob = random.uniform(0, 1)
340
+
341
+ if mutation_prob > bad_genomes_mutation_prob:
342
+ genome_W = good_weights[i]
343
+ genome_act = good_activations[i]
344
+
345
+ fitness_index = int(len(bad_weights) / 2 + i)
346
+
347
+ else:
348
+ genome_W = bad_weights[i]
349
+ genome_act = bad_activations[i]
350
+
351
+ fitness_index = i
352
+
353
+ mutated_W[i], mutated_act[i] = mutation(genome_W,
354
+ genome_act,
355
+ activation_mutate_prob=activation_mutate_prob,
356
+ activation_add_prob=activation_mutate_add_prob,
357
+ activation_delete_prob=activation_mutate_delete_prob,
358
+ activation_change_prob=activation_mutate_change_prob,
359
+ weight_mutate_prob=weight_mutate_prob,
360
+ threshold=weight_mutate_rate,
361
+ genome_fitness=normalized_fitness[fitness_index]
362
+ )
366
363
 
367
364
  if bar_status: progress.update(1)
368
365
 
369
- weights = np.vstack((bad_weights, good_weights))
370
- activation_potentiations = bad_activations + good_activations
366
+ if save_best_genome:
367
+ child_W[-1] = best_weight
368
+ child_act[-1] = best_activations
369
+
370
+ weights = np.vstack((child_W, mutated_W))
371
+ activation_potentiations = child_act + mutated_act
371
372
 
372
373
  ### INFO PRINTING CONSOLE
373
374
 
@@ -378,7 +379,6 @@ def evolver(weights,
378
379
  print(" STRATEGY: ", strategy)
379
380
  print(" CROSS OVER MODE: ", cross_over_mode)
380
381
  print(" POLICY: ", policy)
381
- print(" MUTATIONS: ", str(mutations))
382
382
  print(" BAD GENOMES MUTATION PROB: ", str(bad_genomes_mutation_prob))
383
383
  print(" GOOD GENOMES MUTATION PROB: ", str(round(1 - bad_genomes_mutation_prob, 2)))
384
384
  print(" BAD GENOMES SELECTION PROB: ", str(bad_genomes_selection_prob))
@@ -737,7 +737,7 @@ def mutation(weight,
737
737
 
738
738
  weight[selected_row, selected_col] = random.uniform(-1, 1)
739
739
 
740
- if int(row_end * col_end) > new_threshold:
740
+ if row_end * col_end > new_threshold:
741
741
  new_threshold += threshold
742
742
  performance_control += 1
743
743
  pass
@@ -745,7 +745,7 @@ def mutation(weight,
745
745
  else:
746
746
  break
747
747
 
748
- if performance_control >= int(row_end * col_end):
748
+ if performance_control == row_end * col_end:
749
749
  break
750
750
 
751
751
  activation_mutate_prob = 1 - activation_mutate_prob
@@ -83,10 +83,9 @@ def evolver(weights,
83
83
  bar_status=True,
84
84
  strategy='normal_selective',
85
85
  target_fitness='max',
86
- mutations=True,
87
86
  bad_genomes_mutation_prob=None,
88
87
  activation_mutate_prob=0.5,
89
- save_best_genom=True,
88
+ save_best_genome=True,
90
89
  fitness_bias=None,
91
90
  cross_over_mode='tpm',
92
91
  activation_mutate_add_prob=0.5,
@@ -145,9 +144,6 @@ def evolver(weights,
145
144
  target_fitness (str, optional): Target fitness strategy for PLANEAT optimization. ('max' maximizes fitness, 'min' minimizes fitness.) Default: 'max'.
146
145
 
147
146
  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`.
148
-
149
- mutations (bool, optional): If True, mutations are applied to the bad genomes and potentially
150
- to the best genomes as well. Default is True.
151
147
 
152
148
  bad_genomes_mutation_prob (float, optional): The probability of applying mutation to the bad genomes.
153
149
  Must be in the range [0, 1]. Also affects the mutation probability of the best genomes inversely.
@@ -156,7 +152,7 @@ def evolver(weights,
156
152
  activation_mutate_prob (float, optional): The probability of applying mutation to the activation functions.
157
153
  Must be in the range [0, 1]. Default is 0.5 (50%).
158
154
 
159
- save_best_genom (bool, optional): If True, ensures that the best genomes are saved and not mutated
155
+ save_best_genome (bool, optional): If True, ensures that the best genomes are saved and not mutated
160
156
  or altered during reproduction. Default is True.
161
157
 
162
158
  cross_over_mode (str, optional): Specifies the crossover method to use. Options:
@@ -305,6 +301,13 @@ def evolver(weights,
305
301
  best_fitness = normalized_fitness[-1]
306
302
  epsilon = cp.finfo(float).eps
307
303
 
304
+ child_W = cp.copy(bad_weights)
305
+ child_act = bad_activations.copy()
306
+
307
+ mutated_W = cp.copy(bad_weights)
308
+ mutated_act = bad_activations.copy()
309
+
310
+
308
311
  for i in range(len(bad_weights)):
309
312
 
310
313
  if policy == 'aggressive':
@@ -319,7 +322,7 @@ def evolver(weights,
319
322
 
320
323
  second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
321
324
 
322
- bad_weights[i], bad_activations[i] = cross_over(first_parent_W,
325
+ child_W[i], child_act[i] = cross_over(first_parent_W,
323
326
  second_parent_W,
324
327
  first_parent_act,
325
328
  second_parent_act,
@@ -334,40 +337,39 @@ def evolver(weights,
334
337
  epsilon=epsilon
335
338
  )
336
339
 
340
+ mutation_prob = random.uniform(0, 1)
337
341
 
338
- if mutations is True:
339
- mutation_prob = random.uniform(0, 1)
340
-
341
- if mutation_prob > bad_genomes_mutation_prob:
342
- if (save_best_genom == True and not np.array_equal(good_weights[i], best_weight)) or save_best_genom == False:
343
-
344
- good_weights[i], good_activations[i] = mutation(good_weights[i],
345
- good_activations[i],
346
- activation_mutate_prob=activation_mutate_prob,
347
- activation_add_prob=activation_mutate_add_prob,
348
- activation_delete_prob=activation_mutate_delete_prob,
349
- activation_change_prob=activation_mutate_change_prob,
350
- weight_mutate_prob=weight_mutate_prob,
351
- threshold=weight_mutate_rate,
352
- genome_fitness=normalized_fitness[i]
353
- )
354
-
355
- elif mutation_prob < bad_genomes_mutation_prob:
356
- bad_weights[i], bad_activations[i] = mutation(bad_weights[i],
357
- bad_activations[i],
358
- activation_mutate_prob=activation_mutate_prob,
359
- activation_add_prob=activation_mutate_add_prob,
360
- activation_delete_prob=activation_mutate_delete_prob,
361
- activation_change_prob=activation_mutate_change_prob,
362
- weight_mutate_prob=weight_mutate_prob,
363
- threshold=weight_mutate_rate,
364
- genome_fitness=normalized_fitness[i]
365
- )
342
+ if mutation_prob > bad_genomes_mutation_prob:
343
+ genome_W = good_weights[i]
344
+ genome_act = good_activations[i]
345
+
346
+ fitness_index = int(len(bad_weights) / 2 + i)
347
+
348
+ else:
349
+ genome_W = bad_weights[i]
350
+ genome_act = bad_activations[i]
351
+
352
+ fitness_index = i
353
+
354
+ mutated_W[i], mutated_act[i] = mutation(genome_W,
355
+ genome_act,
356
+ activation_mutate_prob=activation_mutate_prob,
357
+ activation_add_prob=activation_mutate_add_prob,
358
+ activation_delete_prob=activation_mutate_delete_prob,
359
+ activation_change_prob=activation_mutate_change_prob,
360
+ weight_mutate_prob=weight_mutate_prob,
361
+ threshold=weight_mutate_rate,
362
+ genome_fitness=normalized_fitness[fitness_index]
363
+ )
366
364
 
367
365
  if bar_status: progress.update(1)
368
366
 
369
- weights = cp.vstack((bad_weights, good_weights))
370
- activation_potentiations = bad_activations + good_activations
367
+ if save_best_genome:
368
+ child_W[-1] = best_weight
369
+ child_act[-1] = best_activations
370
+
371
+ weights = cp.vstack((child_W, mutated_W))
372
+ activation_potentiations = child_act + mutated_act
371
373
 
372
374
  ### INFO PRINTING CONSOLE
373
375
 
@@ -378,7 +380,6 @@ def evolver(weights,
378
380
  print(" STRATEGY: ", strategy)
379
381
  print(" CROSS OVER MODE: ", cross_over_mode)
380
382
  print(" POLICY: ", policy)
381
- print(" MUTATIONS: ", str(mutations))
382
383
  print(" BAD GENOMES MUTATION PROB: ", str(bad_genomes_mutation_prob))
383
384
  print(" GOOD GENOMES MUTATION PROB: ", str(round(1 - bad_genomes_mutation_prob, 2)))
384
385
  print(" WEIGHT MUTATE PROB: ", str(weight_mutate_prob))
@@ -741,7 +742,7 @@ def mutation(weight,
741
742
 
742
743
  weight[selected_row, selected_col] = random.uniform(-1, 1)
743
744
 
744
- if int(row_end * col_end) > new_threshold:
745
+ if row_end * col_end > new_threshold:
745
746
  new_threshold += threshold
746
747
  performance_control += 1
747
748
  pass
@@ -749,7 +750,7 @@ def mutation(weight,
749
750
  else:
750
751
  break
751
752
 
752
- if performance_control >= int(row_end * col_end):
753
+ if performance_control >= row_end * col_end:
753
754
  break
754
755
 
755
756
  activation_mutate_prob = 1 - activation_mutate_prob
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.2.3
3
+ Version: 4.2.4
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=WEa6P6TMj_krls2lUT03x8-D9kFttdmY3Ebk0ODmt40,639
1
+ pyerualjetwork/__init__.py,sha256=OzpuhZgLGS0elbMyM1OUEWph9js8D_LtnlhDbKTb1YQ,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=YOBF2CqGu400Zk6xuraP0X8WzMNyejpZc5tdVV4dEvE,32219
15
15
  pyerualjetwork/plan_cuda.py,sha256=OKK0pmJYLQd5-dJ1aLiyWiZRBmoUp1zBkFxRcxnWBVI,33610
16
- pyerualjetwork/planeat.py,sha256=hMSyrSPipOxKgOqyoAiZtniVgxPQxc4rRsvEEMOS2Ng,40757
17
- pyerualjetwork/planeat_cuda.py,sha256=9uopmM-gTZpSb0EOExrOZPT8FF5BqDdEfCX0zYQb9QU,40712
16
+ pyerualjetwork/planeat.py,sha256=4XcmQhMHXA6hUWsDZXC2T3I18BeSP4V-GmPYToGR0kg,39638
17
+ pyerualjetwork/planeat_cuda.py,sha256=xaDqH0kWwkmjx-YrBIuLoE1G26qk6rjuOvkH8oRWqyI,39598
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.3.dist-info/METADATA,sha256=f5KIbL0mISOhbhHGoj3WhXS0chLm6GSyEq3dsnyeYrQ,7912
22
- pyerualjetwork-4.2.3.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
- pyerualjetwork-4.2.3.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
- pyerualjetwork-4.2.3.dist-info/RECORD,,
21
+ pyerualjetwork-4.2.4.dist-info/METADATA,sha256=szwh-uHCigwGGd0VCHcyVWixXmpfOncfs6VrMm6y1Vg,7912
22
+ pyerualjetwork-4.2.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
+ pyerualjetwork-4.2.4.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
+ pyerualjetwork-4.2.4.dist-info/RECORD,,