pyerualjetwork 4.2.0b1__py3-none-any.whl → 4.2.0b3__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.
@@ -48,7 +48,7 @@ for package_name in package_names:
48
48
 
49
49
  print(f"PyerualJetwork is ready to use with {err} errors")
50
50
 
51
- __version__ = "4.2.0b1"
51
+ __version__ = "4.2.0b3"
52
52
  __update__ = "* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES\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"
53
53
 
54
54
  def print_version(__version__):
pyerualjetwork/planeat.py CHANGED
@@ -248,6 +248,8 @@ def evolver(weights,
248
248
  else:
249
249
  raise ValueError("strategy parameter must be: 'normal_selective' or 'more_selective' or 'less_selective'")
250
250
 
251
+ if policy == 'explorer': fitness_bias = 0
252
+
251
253
  if ((activation_mutate_add_prob < 0 or activation_mutate_add_prob > 1) or
252
254
  (activation_mutate_change_prob < 0 or activation_mutate_change_prob > 1) or
253
255
  (activation_mutate_delete_prob < 0 or activation_mutate_delete_prob > 1) or
@@ -303,15 +305,13 @@ def evolver(weights,
303
305
  normalized_fitness = abs(normalization(fitness, dtype=dtype))
304
306
 
305
307
  best_fitness = normalized_fitness[-1]
306
-
307
- child_W = np.copy(bad_weights)
308
- child_act = bad_activations.copy()
308
+ epsilon = np.finfo(float).eps
309
309
 
310
310
  for i in range(len(bad_weights)):
311
311
  second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
312
312
 
313
313
  if policy == 'aggresive':
314
- child_W[i], child_act[i] = cross_over(best_weights,
314
+ bad_weights[i], bad_activations[i] = cross_over(best_weights,
315
315
  second_parent_W,
316
316
  best_activations,
317
317
  second_parent_act,
@@ -322,10 +322,11 @@ def evolver(weights,
322
322
  bad_genomes_selection_prob=bad_genomes_selection_prob,
323
323
  first_parent_fitness=best_fitness,
324
324
  fitness_bias=fitness_bias,
325
- second_parent_fitness=normalized_fitness[s_i]
325
+ second_parent_fitness=normalized_fitness[s_i],
326
+ epsilon=epsilon
326
327
  )
327
328
  elif policy == 'explorer':
328
- child_W[i], child_act[i] = cross_over(good_weights[i],
329
+ bad_weights[i], bad_activations[i] = cross_over(good_weights[i],
329
330
  second_parent_W,
330
331
  good_activations[i],
331
332
  second_parent_act,
@@ -336,7 +337,8 @@ def evolver(weights,
336
337
  bad_genomes_selection_prob=bad_genomes_selection_prob,
337
338
  first_parent_fitness=normalized_fitness[i],
338
339
  fitness_bias=fitness_bias,
339
- second_parent_fitness=normalized_fitness[s_i]
340
+ second_parent_fitness=normalized_fitness[s_i],
341
+ epsilon=epsilon
340
342
  )
341
343
 
342
344
  else: raise ValueError("policy parameter must be: 'aggresive' or 'explorer'")
@@ -354,7 +356,8 @@ def evolver(weights,
354
356
  activation_change_prob=activation_mutate_change_prob,
355
357
  weight_mutate_prob=weight_mutate_prob,
356
358
  threshold=weight_mutate_rate,
357
- genome_fitness=normalized_fitness[i]
359
+ genome_fitness=normalized_fitness[i],
360
+ epsilon=epsilon
358
361
  )
359
362
 
360
363
  elif mutation_prob < bad_genomes_mutation_prob:
@@ -366,13 +369,14 @@ def evolver(weights,
366
369
  activation_change_prob=activation_mutate_change_prob,
367
370
  weight_mutate_prob=weight_mutate_prob,
368
371
  threshold=weight_mutate_rate,
369
- genome_fitness=normalized_fitness[i]
372
+ genome_fitness=normalized_fitness[i],
373
+ epsilon=epsilon
370
374
  )
371
375
 
372
376
  if bar_status: progress.update(1)
373
377
 
374
- weights = np.vstack((child_W, good_weights))
375
- activation_potentiations = child_act + good_activations
378
+ weights = np.vstack((bad_weights, good_weights))
379
+ activation_potentiations = bad_activations + good_activations
376
380
 
377
381
  ### INFO PRINTING CONSOLE
378
382
 
@@ -492,7 +496,8 @@ def cross_over(first_parent_W,
492
496
  bad_genomes_selection_prob,
493
497
  first_parent_fitness,
494
498
  second_parent_fitness,
495
- fitness_bias):
499
+ fitness_bias,
500
+ epsilon):
496
501
  """
497
502
  Performs a crossover operation on two sets of weights and activation functions.
498
503
  This function combines two individuals (represented by their weights and activation functions)
@@ -500,22 +505,35 @@ def cross_over(first_parent_W,
500
505
 
501
506
  Args:
502
507
  first_parent_W (numpy.ndarray): The weight matrix of the first individual (parent).
508
+
503
509
  second_parent_W (numpy.ndarray): The weight matrix of the second individual (parent).
510
+
504
511
  first_parent_act (str or list): The activation function(s) of the first individual.
512
+
505
513
  second_parent_act (str or list): The activation function(s) of the second individual.
514
+
506
515
  cross_over_mode (str): Determines the crossover method to be used. Options:
507
516
  - 'tpm': Two-Point Matrix Crossover, where sub-matrices of weights are swapped between parents.
517
+
508
518
  activation_selection_add_prob (float): Probability of adding new activation functions
509
519
  from the second parent to the child genome.
520
+
510
521
  activation_selection_change_prob (float): Probability of replacing an activation function in the child genome
511
522
  with one from the second parent.
523
+
512
524
  activation_selection_rate (float): Determines how quickly activation functions are added or replaced
513
525
  during the crossover process.
526
+
514
527
  bad_genomes_selection_prob (float): Probability of selecting a "bad" genome for replacement with the offspring.
528
+
515
529
  first_parent_fitness (float): Fitness score of the first parent.
530
+
516
531
  second_parent_fitness (float): Fitness score of the second parent.
532
+
517
533
  fitness_bias (float): A bias factor used to favor fitter parents during crossover operations.
518
534
 
535
+ epsilon (float): Small epsilon constant
536
+
519
537
  Returns:
520
538
  tuple: A tuple containing:
521
539
  - child_W (numpy.ndarray): The weight matrix of the new individual created by crossover.
@@ -540,7 +558,8 @@ def cross_over(first_parent_W,
540
558
  bad_genomes_selection_prob=0.7,
541
559
  first_parent_fitness=0.9,
542
560
  second_parent_fitness=0.85,
543
- fitness_bias=0.6
561
+ fitness_bias=0.6,
562
+ epsilon=np.finfo.eps
544
563
  )
545
564
  ```
546
565
  """
@@ -563,7 +582,7 @@ def cross_over(first_parent_W,
563
582
 
564
583
  undominant_parent_W = np.copy(second_parent_W)
565
584
  undominant_parent_act = second_parent_act
566
- succes = second_parent_fitness
585
+ succes = second_parent_fitness + epsilon
567
586
 
568
587
  elif decision == 'second_parent':
569
588
  dominant_parent_W = np.copy(second_parent_W)
@@ -571,7 +590,7 @@ def cross_over(first_parent_W,
571
590
 
572
591
  undominant_parent_W = np.copy(first_parent_W)
573
592
  undominant_parent_act = first_parent_act
574
- succes = first_parent_fitness
593
+ succes = first_parent_fitness + epsilon
575
594
 
576
595
  while True:
577
596
 
@@ -589,18 +608,17 @@ def cross_over(first_parent_W,
589
608
  selection_bias = random.uniform(0, 1)
590
609
 
591
610
  if fitness_bias > selection_bias:
592
- row_cut_start = math.floor(row_cut_start * succes)
593
- row_cut_end = math.ceil(row_cut_end * succes)
611
+ row_cut_start = math.floor(row_cut_start * (succes + epsilon))
612
+ row_cut_end = math.ceil(row_cut_end * (succes + epsilon))
594
613
 
595
- col_cut_start = math.floor(col_cut_start * succes)
596
- col_cut_end = math.ceil(col_cut_end * succes)
614
+ col_cut_start = math.floor(col_cut_start * (succes + epsilon))
615
+ col_cut_end = math.ceil(col_cut_end * (succes + epsilon))
597
616
 
598
617
  child_W = dominant_parent_W
599
618
 
600
619
  if cross_over_mode == 'tpm':
601
620
  child_W[row_cut_start:row_cut_end, col_cut_start:col_cut_end] = undominant_parent_W[row_cut_start:row_cut_end, col_cut_start:col_cut_end]
602
621
 
603
-
604
622
  if isinstance(dominant_parent_act, str): dominant_parent_act = [dominant_parent_act]
605
623
  if isinstance(undominant_parent_act, str): undominant_parent_act = [undominant_parent_act]
606
624
 
@@ -661,7 +679,8 @@ def mutation(weight,
661
679
  activation_change_prob,
662
680
  weight_mutate_prob,
663
681
  threshold,
664
- genome_fitness):
682
+ genome_fitness,
683
+ epsilon):
665
684
  """
666
685
  Performs mutation on the given weight matrix and activation functions.
667
686
  - The weight matrix is mutated by randomly changing its values based on the mutation probability.
@@ -669,14 +688,25 @@ def mutation(weight,
669
688
 
670
689
  Args:
671
690
  weight (numpy.ndarray): The weight matrix to mutate.
691
+
672
692
  activations (list): The list of activation functions to mutate.
693
+
673
694
  activation_mutate_prob (float): The overall probability of mutating activation functions.
695
+
674
696
  activation_add_prob (float): Probability of adding a new activation function.
697
+
675
698
  activation_delete_prob (float): Probability of removing an existing activation function.
699
+
676
700
  activation_change_prob (float): Probability of replacing an existing activation function with a new one.
701
+
677
702
  weight_mutate_prob (float): The probability of mutating weight matrix.
703
+
678
704
  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.
705
+
679
706
  genome_fitness (float): Fitness value of genome
707
+
708
+ epsilon (float): Small epsilon constant
709
+
680
710
  Returns:
681
711
  tuple: A tuple containing:
682
712
  - mutated_weight (numpy.ndarray): The weight matrix after mutation.
@@ -704,8 +734,8 @@ def mutation(weight,
704
734
  start = 0
705
735
  row_end = weight.shape[0]
706
736
  col_end = weight.shape[1]
707
-
708
- threshold = threshold * genome_fitness
737
+
738
+ threshold = threshold * (genome_fitness + epsilon)
709
739
  new_threshold = threshold
710
740
 
711
741
  while True:
@@ -249,6 +249,8 @@ def evolver(weights,
249
249
  else:
250
250
  raise ValueError("strategy parameter must be: 'normal_selective' or 'more_selective' or 'less_selective'")
251
251
 
252
+ if policy =='explorer': fitness_bias = 0
253
+
252
254
  if ((activation_mutate_add_prob < 0 or activation_mutate_add_prob > 1) or
253
255
  (activation_mutate_change_prob < 0 or activation_mutate_change_prob > 1) or
254
256
  (activation_mutate_delete_prob < 0 or activation_mutate_delete_prob > 1) or
@@ -303,15 +305,13 @@ def evolver(weights,
303
305
  normalized_fitness = abs(normalization(fitness, dtype=dtype))
304
306
 
305
307
  best_fitness = normalized_fitness[-1]
306
-
307
- child_W = cp.copy(bad_weights)
308
- child_act = bad_activations.copy()
308
+ epsilon = cp.finfo(float).eps
309
309
 
310
310
  for i in range(len(bad_weights)):
311
311
  second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
312
312
 
313
313
  if policy == 'aggresive':
314
- child_W[i], child_act[i] = cross_over(best_weights,
314
+ bad_weights[i], bad_activations[i] = cross_over(best_weights,
315
315
  second_parent_W,
316
316
  best_activations,
317
317
  second_parent_act,
@@ -322,10 +322,11 @@ def evolver(weights,
322
322
  bad_genomes_selection_prob=bad_genomes_selection_prob,
323
323
  first_parent_fitness=best_fitness,
324
324
  fitness_bias=fitness_bias,
325
- second_parent_fitness=normalized_fitness[s_i]
325
+ second_parent_fitness=normalized_fitness[s_i],
326
+ epsilon=epsilon
326
327
  )
327
328
  elif policy == 'explorer':
328
- child_W[i], child_act[i] = cross_over(good_weights[i],
329
+ bad_weights[i], bad_activations[i] = cross_over(good_weights[i],
329
330
  second_parent_W,
330
331
  good_activations[i],
331
332
  second_parent_act,
@@ -336,9 +337,10 @@ def evolver(weights,
336
337
  bad_genomes_selection_prob=bad_genomes_selection_prob,
337
338
  first_parent_fitness=normalized_fitness[i],
338
339
  fitness_bias=fitness_bias,
339
- second_parent_fitness=normalized_fitness[s_i]
340
+ second_parent_fitness=normalized_fitness[s_i],
341
+ epsilon=epsilon
340
342
  )
341
-
343
+
342
344
  else: raise ValueError("policy parameter must be: 'aggresive' or 'explorer'")
343
345
 
344
346
  if mutations is True:
@@ -354,7 +356,8 @@ def evolver(weights,
354
356
  activation_change_prob=activation_mutate_change_prob,
355
357
  weight_mutate_prob=weight_mutate_prob,
356
358
  threshold=weight_mutate_rate,
357
- genome_fitness=normalized_fitness[i]
359
+ genome_fitness=normalized_fitness[i],
360
+ epsilon=epsilon
358
361
  )
359
362
 
360
363
  elif mutation_prob < bad_genomes_mutation_prob:
@@ -366,13 +369,14 @@ def evolver(weights,
366
369
  activation_change_prob=activation_mutate_change_prob,
367
370
  weight_mutate_prob=weight_mutate_prob,
368
371
  threshold=weight_mutate_rate,
369
- genome_fitness=normalized_fitness[i]
372
+ genome_fitness=normalized_fitness[i],
373
+ epsilon=epsilon
370
374
  )
371
375
 
372
376
  if bar_status: progress.update(1)
373
377
 
374
- weights = cp.vstack((child_W, good_weights))
375
- activation_potentiations = child_act + good_activations
378
+ weights = cp.vstack((bad_weights, good_weights))
379
+ activation_potentiations = bad_activations + good_activations
376
380
 
377
381
  ### INFO PRINTING CONSOLE
378
382
 
@@ -495,7 +499,8 @@ def cross_over(first_parent_W,
495
499
  bad_genomes_selection_prob,
496
500
  first_parent_fitness,
497
501
  second_parent_fitness,
498
- fitness_bias):
502
+ fitness_bias,
503
+ epsilon):
499
504
  """
500
505
  Performs a crossover operation on two sets of weights and activation functions.
501
506
  This function combines two individuals (represented by their weights and activation functions)
@@ -530,6 +535,8 @@ def cross_over(first_parent_W,
530
535
 
531
536
  fitness_bias (float): A bias factor used to favor fitter parents during crossover operations.
532
537
 
538
+ epsilon (float): Small epsilon constant
539
+
533
540
  Returns:
534
541
  tuple: A tuple containing:
535
542
  - child_W (numpy.ndarray): The weight matrix of the new individual created by crossover.
@@ -554,7 +561,8 @@ def cross_over(first_parent_W,
554
561
  bad_genomes_selection_prob=0.7,
555
562
  first_parent_fitness=0.9,
556
563
  second_parent_fitness=0.85,
557
- fitness_bias=0.6
564
+ fitness_bias=0.6,
565
+ epsilon=cp.finfo.eps
558
566
  )
559
567
  ```
560
568
  """
@@ -577,7 +585,7 @@ def cross_over(first_parent_W,
577
585
 
578
586
  undominant_parent_W = cp.copy(second_parent_W)
579
587
  undominant_parent_act = second_parent_act
580
- succes = second_parent_fitness
588
+ succes = second_parent_fitness + epsilon
581
589
 
582
590
  elif decision == 'second_parent':
583
591
  dominant_parent_W = cp.copy(second_parent_W)
@@ -585,7 +593,7 @@ def cross_over(first_parent_W,
585
593
 
586
594
  undominant_parent_W = cp.copy(first_parent_W)
587
595
  undominant_parent_act = first_parent_act
588
- succes = first_parent_fitness
596
+ succes = first_parent_fitness + epsilon
589
597
 
590
598
  while True:
591
599
 
@@ -676,7 +684,8 @@ def mutation(weight,
676
684
  activation_change_prob,
677
685
  weight_mutate_prob,
678
686
  threshold,
679
- genome_fitness):
687
+ genome_fitness,
688
+ epsilon):
680
689
  """
681
690
  Performs mutation on the given weight matrix and activation functions.
682
691
  - The weight matrix is mutated by randomly changing its values based on the mutation probability.
@@ -701,6 +710,8 @@ def mutation(weight,
701
710
 
702
711
  genome_fitness (float): Fitness value of genome
703
712
 
713
+ epsilon (float): Small epsilon constant
714
+
704
715
  Returns:
705
716
  tuple: A tuple containing:
706
717
  - mutated_weight (numpy.ndarray): The weight matrix after mutation.
@@ -729,7 +740,7 @@ def mutation(weight,
729
740
  row_end = weight.shape[0]
730
741
  col_end = weight.shape[1]
731
742
 
732
- threshold = threshold * genome_fitness
743
+ threshold = threshold * (genome_fitness + epsilon)
733
744
  new_threshold = threshold
734
745
 
735
746
  while True:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.2.0b1
3
+ Version: 4.2.0b3
4
4
  Summary: PyerualJetwork is a machine learning library written in Python for professionals, incorporating advanced, unique, new, and modern techniques.
5
5
  Author: Hasan Can Beydili
6
6
  Author-email: tchasancan@gmail.com
@@ -1,4 +1,4 @@
1
- pyerualjetwork/__init__.py,sha256=UeD-cBkv904KlDncOWplEjPeNW9jPMkyjdaaTYJUDnY,2177
1
+ pyerualjetwork/__init__.py,sha256=uTnwBPgD5ZsDGWn8CSyVs_DxNNdEbvJt0A1qrYmZtVM,2177
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=HjyW2QE18age6J8iG0jpbwqGOylL_nM-vE2CLbP9Wes,14690
@@ -13,12 +13,12 @@ pyerualjetwork/model_operations.py,sha256=hnhR8dtoICNJWIwGgJ65-LN3GYN_DYH4LMe6Yp
13
13
  pyerualjetwork/model_operations_cuda.py,sha256=XnKKq54ZLaqCm-NaJ6d8IToACKcKg2Ttq6moowVRRWo,13365
14
14
  pyerualjetwork/plan.py,sha256=EobwajGSIgbOujkzDKb-Kea0LGRHqpK3Xy1Le8VBAe8,34422
15
15
  pyerualjetwork/plan_cuda.py,sha256=iCcAHLzVw_VyjhkFHXzBWiedwbnpI1MCXNJgSDgZxWw,36065
16
- pyerualjetwork/planeat.py,sha256=--KO3cUAvUJ0L-qF2w2doHFX_UZvv0SsN-voPWJ7joY,41454
17
- pyerualjetwork/planeat_cuda.py,sha256=g-gdSAA-a1ML8GEUL3qOrSCd-XaFH7glkbqC0g_SC10,41655
16
+ pyerualjetwork/planeat.py,sha256=nAVyCU78G00ac1cJ5XEsnmOnhMXuXCpbnS79pfaWqf8,42260
17
+ pyerualjetwork/planeat_cuda.py,sha256=QorgaigpmtTSEjSvlfPy87jKH449Bve68AVOwRBYaiw,42212
18
18
  pyerualjetwork/ui.py,sha256=wu2BhU1k-w3Kcho5Jtq4SEKe68ftaUeRGneUOSCVDjU,575
19
19
  pyerualjetwork/visualizations.py,sha256=QaYSIyVkJZ8NqpBKArQKkI1y37nCQo_KIM98IMssnRc,28766
20
20
  pyerualjetwork/visualizations_cuda.py,sha256=F60vQ92AXlMgBka3InXnOtGoM25vQJAlBIU2AlYTwks,29200
21
- pyerualjetwork-4.2.0b1.dist-info/METADATA,sha256=ozbvSqNZWZ6eYKJVSRtkZHxHao8TuC0s2VHV53tsh2I,7795
22
- pyerualjetwork-4.2.0b1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
- pyerualjetwork-4.2.0b1.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
- pyerualjetwork-4.2.0b1.dist-info/RECORD,,
21
+ pyerualjetwork-4.2.0b3.dist-info/METADATA,sha256=jPKsUsndSriMwL6FvZOQ2HThwHTATJ4eSHn-c63IqZ8,7795
22
+ pyerualjetwork-4.2.0b3.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
+ pyerualjetwork-4.2.0b3.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
+ pyerualjetwork-4.2.0b3.dist-info/RECORD,,