pyerualjetwork 4.2.0b2__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.0b2"
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
@@ -305,6 +305,7 @@ def evolver(weights,
305
305
  normalized_fitness = abs(normalization(fitness, dtype=dtype))
306
306
 
307
307
  best_fitness = normalized_fitness[-1]
308
+ epsilon = np.finfo(float).eps
308
309
 
309
310
  for i in range(len(bad_weights)):
310
311
  second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
@@ -321,7 +322,8 @@ def evolver(weights,
321
322
  bad_genomes_selection_prob=bad_genomes_selection_prob,
322
323
  first_parent_fitness=best_fitness,
323
324
  fitness_bias=fitness_bias,
324
- second_parent_fitness=normalized_fitness[s_i]
325
+ second_parent_fitness=normalized_fitness[s_i],
326
+ epsilon=epsilon
325
327
  )
326
328
  elif policy == 'explorer':
327
329
  bad_weights[i], bad_activations[i] = cross_over(good_weights[i],
@@ -335,7 +337,8 @@ def evolver(weights,
335
337
  bad_genomes_selection_prob=bad_genomes_selection_prob,
336
338
  first_parent_fitness=normalized_fitness[i],
337
339
  fitness_bias=fitness_bias,
338
- second_parent_fitness=normalized_fitness[s_i]
340
+ second_parent_fitness=normalized_fitness[s_i],
341
+ epsilon=epsilon
339
342
  )
340
343
 
341
344
  else: raise ValueError("policy parameter must be: 'aggresive' or 'explorer'")
@@ -353,7 +356,8 @@ def evolver(weights,
353
356
  activation_change_prob=activation_mutate_change_prob,
354
357
  weight_mutate_prob=weight_mutate_prob,
355
358
  threshold=weight_mutate_rate,
356
- genome_fitness=normalized_fitness[i]
359
+ genome_fitness=normalized_fitness[i],
360
+ epsilon=epsilon
357
361
  )
358
362
 
359
363
  elif mutation_prob < bad_genomes_mutation_prob:
@@ -365,7 +369,8 @@ def evolver(weights,
365
369
  activation_change_prob=activation_mutate_change_prob,
366
370
  weight_mutate_prob=weight_mutate_prob,
367
371
  threshold=weight_mutate_rate,
368
- genome_fitness=normalized_fitness[i]
372
+ genome_fitness=normalized_fitness[i],
373
+ epsilon=epsilon
369
374
  )
370
375
 
371
376
  if bar_status: progress.update(1)
@@ -491,7 +496,8 @@ def cross_over(first_parent_W,
491
496
  bad_genomes_selection_prob,
492
497
  first_parent_fitness,
493
498
  second_parent_fitness,
494
- fitness_bias):
499
+ fitness_bias,
500
+ epsilon):
495
501
  """
496
502
  Performs a crossover operation on two sets of weights and activation functions.
497
503
  This function combines two individuals (represented by their weights and activation functions)
@@ -499,22 +505,35 @@ def cross_over(first_parent_W,
499
505
 
500
506
  Args:
501
507
  first_parent_W (numpy.ndarray): The weight matrix of the first individual (parent).
508
+
502
509
  second_parent_W (numpy.ndarray): The weight matrix of the second individual (parent).
510
+
503
511
  first_parent_act (str or list): The activation function(s) of the first individual.
512
+
504
513
  second_parent_act (str or list): The activation function(s) of the second individual.
514
+
505
515
  cross_over_mode (str): Determines the crossover method to be used. Options:
506
516
  - 'tpm': Two-Point Matrix Crossover, where sub-matrices of weights are swapped between parents.
517
+
507
518
  activation_selection_add_prob (float): Probability of adding new activation functions
508
519
  from the second parent to the child genome.
520
+
509
521
  activation_selection_change_prob (float): Probability of replacing an activation function in the child genome
510
522
  with one from the second parent.
523
+
511
524
  activation_selection_rate (float): Determines how quickly activation functions are added or replaced
512
525
  during the crossover process.
526
+
513
527
  bad_genomes_selection_prob (float): Probability of selecting a "bad" genome for replacement with the offspring.
528
+
514
529
  first_parent_fitness (float): Fitness score of the first parent.
530
+
515
531
  second_parent_fitness (float): Fitness score of the second parent.
532
+
516
533
  fitness_bias (float): A bias factor used to favor fitter parents during crossover operations.
517
534
 
535
+ epsilon (float): Small epsilon constant
536
+
518
537
  Returns:
519
538
  tuple: A tuple containing:
520
539
  - child_W (numpy.ndarray): The weight matrix of the new individual created by crossover.
@@ -539,7 +558,8 @@ def cross_over(first_parent_W,
539
558
  bad_genomes_selection_prob=0.7,
540
559
  first_parent_fitness=0.9,
541
560
  second_parent_fitness=0.85,
542
- fitness_bias=0.6
561
+ fitness_bias=0.6,
562
+ epsilon=np.finfo.eps
543
563
  )
544
564
  ```
545
565
  """
@@ -562,7 +582,7 @@ def cross_over(first_parent_W,
562
582
 
563
583
  undominant_parent_W = np.copy(second_parent_W)
564
584
  undominant_parent_act = second_parent_act
565
- succes = second_parent_fitness
585
+ succes = second_parent_fitness + epsilon
566
586
 
567
587
  elif decision == 'second_parent':
568
588
  dominant_parent_W = np.copy(second_parent_W)
@@ -570,7 +590,7 @@ def cross_over(first_parent_W,
570
590
 
571
591
  undominant_parent_W = np.copy(first_parent_W)
572
592
  undominant_parent_act = first_parent_act
573
- succes = first_parent_fitness
593
+ succes = first_parent_fitness + epsilon
574
594
 
575
595
  while True:
576
596
 
@@ -588,18 +608,17 @@ def cross_over(first_parent_W,
588
608
  selection_bias = random.uniform(0, 1)
589
609
 
590
610
  if fitness_bias > selection_bias:
591
- row_cut_start = math.floor(row_cut_start * succes)
592
- 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))
593
613
 
594
- col_cut_start = math.floor(col_cut_start * succes)
595
- 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))
596
616
 
597
617
  child_W = dominant_parent_W
598
618
 
599
619
  if cross_over_mode == 'tpm':
600
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]
601
621
 
602
-
603
622
  if isinstance(dominant_parent_act, str): dominant_parent_act = [dominant_parent_act]
604
623
  if isinstance(undominant_parent_act, str): undominant_parent_act = [undominant_parent_act]
605
624
 
@@ -660,7 +679,8 @@ def mutation(weight,
660
679
  activation_change_prob,
661
680
  weight_mutate_prob,
662
681
  threshold,
663
- genome_fitness):
682
+ genome_fitness,
683
+ epsilon):
664
684
  """
665
685
  Performs mutation on the given weight matrix and activation functions.
666
686
  - The weight matrix is mutated by randomly changing its values based on the mutation probability.
@@ -668,14 +688,25 @@ def mutation(weight,
668
688
 
669
689
  Args:
670
690
  weight (numpy.ndarray): The weight matrix to mutate.
691
+
671
692
  activations (list): The list of activation functions to mutate.
693
+
672
694
  activation_mutate_prob (float): The overall probability of mutating activation functions.
695
+
673
696
  activation_add_prob (float): Probability of adding a new activation function.
697
+
674
698
  activation_delete_prob (float): Probability of removing an existing activation function.
699
+
675
700
  activation_change_prob (float): Probability of replacing an existing activation function with a new one.
701
+
676
702
  weight_mutate_prob (float): The probability of mutating weight matrix.
703
+
677
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
+
678
706
  genome_fitness (float): Fitness value of genome
707
+
708
+ epsilon (float): Small epsilon constant
709
+
679
710
  Returns:
680
711
  tuple: A tuple containing:
681
712
  - mutated_weight (numpy.ndarray): The weight matrix after mutation.
@@ -703,8 +734,8 @@ def mutation(weight,
703
734
  start = 0
704
735
  row_end = weight.shape[0]
705
736
  col_end = weight.shape[1]
706
-
707
- threshold = threshold * genome_fitness
737
+
738
+ threshold = threshold * (genome_fitness + epsilon)
708
739
  new_threshold = threshold
709
740
 
710
741
  while True:
@@ -305,6 +305,7 @@ def evolver(weights,
305
305
  normalized_fitness = abs(normalization(fitness, dtype=dtype))
306
306
 
307
307
  best_fitness = normalized_fitness[-1]
308
+ epsilon = cp.finfo(float).eps
308
309
 
309
310
  for i in range(len(bad_weights)):
310
311
  second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
@@ -321,7 +322,8 @@ def evolver(weights,
321
322
  bad_genomes_selection_prob=bad_genomes_selection_prob,
322
323
  first_parent_fitness=best_fitness,
323
324
  fitness_bias=fitness_bias,
324
- second_parent_fitness=normalized_fitness[s_i]
325
+ second_parent_fitness=normalized_fitness[s_i],
326
+ epsilon=epsilon
325
327
  )
326
328
  elif policy == 'explorer':
327
329
  bad_weights[i], bad_activations[i] = cross_over(good_weights[i],
@@ -335,9 +337,10 @@ def evolver(weights,
335
337
  bad_genomes_selection_prob=bad_genomes_selection_prob,
336
338
  first_parent_fitness=normalized_fitness[i],
337
339
  fitness_bias=fitness_bias,
338
- second_parent_fitness=normalized_fitness[s_i]
340
+ second_parent_fitness=normalized_fitness[s_i],
341
+ epsilon=epsilon
339
342
  )
340
-
343
+
341
344
  else: raise ValueError("policy parameter must be: 'aggresive' or 'explorer'")
342
345
 
343
346
  if mutations is True:
@@ -353,7 +356,8 @@ def evolver(weights,
353
356
  activation_change_prob=activation_mutate_change_prob,
354
357
  weight_mutate_prob=weight_mutate_prob,
355
358
  threshold=weight_mutate_rate,
356
- genome_fitness=normalized_fitness[i]
359
+ genome_fitness=normalized_fitness[i],
360
+ epsilon=epsilon
357
361
  )
358
362
 
359
363
  elif mutation_prob < bad_genomes_mutation_prob:
@@ -365,7 +369,8 @@ def evolver(weights,
365
369
  activation_change_prob=activation_mutate_change_prob,
366
370
  weight_mutate_prob=weight_mutate_prob,
367
371
  threshold=weight_mutate_rate,
368
- genome_fitness=normalized_fitness[i]
372
+ genome_fitness=normalized_fitness[i],
373
+ epsilon=epsilon
369
374
  )
370
375
 
371
376
  if bar_status: progress.update(1)
@@ -494,7 +499,8 @@ def cross_over(first_parent_W,
494
499
  bad_genomes_selection_prob,
495
500
  first_parent_fitness,
496
501
  second_parent_fitness,
497
- fitness_bias):
502
+ fitness_bias,
503
+ epsilon):
498
504
  """
499
505
  Performs a crossover operation on two sets of weights and activation functions.
500
506
  This function combines two individuals (represented by their weights and activation functions)
@@ -529,6 +535,8 @@ def cross_over(first_parent_W,
529
535
 
530
536
  fitness_bias (float): A bias factor used to favor fitter parents during crossover operations.
531
537
 
538
+ epsilon (float): Small epsilon constant
539
+
532
540
  Returns:
533
541
  tuple: A tuple containing:
534
542
  - child_W (numpy.ndarray): The weight matrix of the new individual created by crossover.
@@ -553,7 +561,8 @@ def cross_over(first_parent_W,
553
561
  bad_genomes_selection_prob=0.7,
554
562
  first_parent_fitness=0.9,
555
563
  second_parent_fitness=0.85,
556
- fitness_bias=0.6
564
+ fitness_bias=0.6,
565
+ epsilon=cp.finfo.eps
557
566
  )
558
567
  ```
559
568
  """
@@ -576,7 +585,7 @@ def cross_over(first_parent_W,
576
585
 
577
586
  undominant_parent_W = cp.copy(second_parent_W)
578
587
  undominant_parent_act = second_parent_act
579
- succes = second_parent_fitness
588
+ succes = second_parent_fitness + epsilon
580
589
 
581
590
  elif decision == 'second_parent':
582
591
  dominant_parent_W = cp.copy(second_parent_W)
@@ -584,7 +593,7 @@ def cross_over(first_parent_W,
584
593
 
585
594
  undominant_parent_W = cp.copy(first_parent_W)
586
595
  undominant_parent_act = first_parent_act
587
- succes = first_parent_fitness
596
+ succes = first_parent_fitness + epsilon
588
597
 
589
598
  while True:
590
599
 
@@ -675,7 +684,8 @@ def mutation(weight,
675
684
  activation_change_prob,
676
685
  weight_mutate_prob,
677
686
  threshold,
678
- genome_fitness):
687
+ genome_fitness,
688
+ epsilon):
679
689
  """
680
690
  Performs mutation on the given weight matrix and activation functions.
681
691
  - The weight matrix is mutated by randomly changing its values based on the mutation probability.
@@ -700,6 +710,8 @@ def mutation(weight,
700
710
 
701
711
  genome_fitness (float): Fitness value of genome
702
712
 
713
+ epsilon (float): Small epsilon constant
714
+
703
715
  Returns:
704
716
  tuple: A tuple containing:
705
717
  - mutated_weight (numpy.ndarray): The weight matrix after mutation.
@@ -728,7 +740,7 @@ def mutation(weight,
728
740
  row_end = weight.shape[0]
729
741
  col_end = weight.shape[1]
730
742
 
731
- threshold = threshold * genome_fitness
743
+ threshold = threshold * (genome_fitness + epsilon)
732
744
  new_threshold = threshold
733
745
 
734
746
  while True:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.2.0b2
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=tVdYMhPnjJvAckaBx6ZO9kvv59yuEQ997QzFlcqcUno,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=AjgCcemtzpgsuM9hndvRQpaDjRy9wOZpRMgWIFZ1k2o,41456
17
- pyerualjetwork/planeat_cuda.py,sha256=_E2-xMcEqUus9SnefjD43FXutmVXt-HTFkQ3d_8q_wQ,41656
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.0b2.dist-info/METADATA,sha256=UU939ACHKQTIXCt4YVsvV6iNtk3UPCCQCTk3nHU9WMc,7795
22
- pyerualjetwork-4.2.0b2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
23
- pyerualjetwork-4.2.0b2.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
24
- pyerualjetwork-4.2.0b2.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,,