pyerualjetwork 4.8b0__py3-none-any.whl → 5__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,44 @@
1
- __version__ = "4.8b0"
1
+ """
2
+
3
+ PyerualJetwork
4
+ ==============
5
+ PyereualJetwork is a large, GPU-accelerated machine learning library in Python designed for professionals and researchers.
6
+ It features PLAN, MLP, and Deep Learning training, as well as ENE (Eugenic NeuroEvolution) for genetic optimization,
7
+ which can also be applied to genetic algorithms or Reinforcement Learning (RL) problems.
8
+ The library includes functions for data pre-processing, visualizations, model saving and loading, prediction and evaluation,
9
+ training, and both detailed and simplified memory management.
10
+
11
+
12
+ Library (CPU) Main Modules:
13
+ ---------------------------
14
+ - neu
15
+ - ene
16
+ - data_operations
17
+ - model_operations
18
+
19
+ Library (GPU) Main Modules:
20
+ ---------------------------
21
+ - neu_cuda
22
+ - ene_cuda
23
+ - data_operations_cuda
24
+ - model_operations_cuda
25
+
26
+ Memory Module:
27
+ --------------
28
+ - memory_operations
29
+
30
+ Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
31
+
32
+ PyerualJetwork document: https://github.com/HCB06/Anaplan/blob/main/Welcome_to_Anaplan/ANAPLAN_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
33
+
34
+ - Author: Hasan Can Beydili
35
+ - YouTube: https://www.youtube.com/@HasanCanBeydili
36
+ - Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
37
+ - Instagram: https://www.instagram.com/canbeydilj
38
+ - Contact: tchasancan@gmail.com
39
+ """
40
+
41
+ __version__ = "5"
2
42
  __update__ = """* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES
3
43
  * PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main
4
44
  * PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
@@ -1,3 +1,33 @@
1
+ """
2
+
3
+
4
+ Data Operations
5
+ ===============
6
+ This module contains functions for handling all operational processes related to data and datasets.
7
+
8
+ Module functions:
9
+ -----------------
10
+ - encode_one_hot()
11
+ - decode_one_hot()
12
+ - split()
13
+ - manuel_balancer()
14
+ - auto_balancer()
15
+ - synthetic_augmentation()
16
+ - non_neg_normalization()
17
+ - normalization()
18
+ - standard_scaler()
19
+
20
+ Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
21
+
22
+ PyerualJetwork document: https://github.com/HCB06/Anaplan/blob/main/Welcome_to_Anaplan/ANAPLAN_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
23
+
24
+ - Author: Hasan Can Beydili
25
+ - YouTube: https://www.youtube.com/@HasanCanBeydili
26
+ - Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
27
+ - Instagram: https://www.instagram.com/canbeydilj
28
+ - Contact: tchasancan@gmail.com
29
+ """
30
+
1
31
  from tqdm import tqdm
2
32
  import numpy as np
3
33
  from colorama import Fore, Style
@@ -383,7 +413,7 @@ def non_neg_normalization(
383
413
  dtype=np.float32
384
414
  ):
385
415
  """
386
- Normalizes the input data [0-1] range.
416
+ Normalizes the input data [0-1] range using max-abs normalization but non negative number.
387
417
  Args:
388
418
  Input (numpy): Input data to be normalized.
389
419
  dtype (numpy.dtype): Data type for the arrays. np.float32 by default. Example: np.float64 or np.float16.
@@ -1,3 +1,33 @@
1
+ """
2
+
3
+
4
+ Data Operations on GPU (CUDA)
5
+ =============================
6
+ This module contains functions for handling all operational processes related to data and datasets on GPU memory.
7
+
8
+ Module functions:
9
+ ---------------
10
+ - encode_one_hot()
11
+ - decode_one_hot()
12
+ - split()
13
+ - manuel_balancer()
14
+ - auto_balancer()
15
+ - synthetic_augmentation()
16
+ - non_neg_normalization()
17
+ - normalization()
18
+ - standard_scaler()
19
+
20
+ Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
21
+
22
+ PyerualJetwork document: https://github.com/HCB06/Anaplan/blob/main/Welcome_to_Anaplan/ANAPLAN_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
23
+
24
+ - Author: Hasan Can Beydili
25
+ - YouTube: https://www.youtube.com/@HasanCanBeydili
26
+ - Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
27
+ - Instagram: https://www.instagram.com/canbeydilj
28
+ - Contact: tchasancan@gmail.com
29
+ """
30
+
1
31
  from tqdm import tqdm
2
32
  import cupy as cp
3
33
  from colorama import Fore, Style
@@ -1,15 +1,31 @@
1
1
  """
2
- MAIN MODULE FOR PLANEAT
2
+
3
+
4
+ ENE (Eugenic NeuroEvolution)
5
+ ============================
6
+
7
+ This module contains all the functions necessary for implementing and testing the ENE (Eugenic NeuroEvolution) algorithm.
8
+ For more information about the ENE algorithm: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PLAN/PLAN.pdf
9
+
10
+ Module functions:
11
+ -----------------
12
+ - evolver()
13
+ - define_genomes()
14
+ - evaluate()
15
+ - cross_over()
16
+ - mutation()
17
+ - dominant_parent_selection()
18
+ - second_parent_selection()
3
19
 
4
20
  Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
5
21
 
6
22
  PyerualJetwork document: https://github.com/HCB06/Anaplan/blob/main/Welcome_to_Anaplan/ANAPLAN_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
7
23
 
8
- @author: Hasan Can Beydili
9
- @YouTube: https://www.youtube.com/@HasanCanBeydili
10
- @Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
11
- @Instagram: https://www.instagram.com/canbeydilj
12
- @contact: tchasancan@gmail.com
24
+ - Author: Hasan Can Beydili
25
+ - YouTube: https://www.youtube.com/@HasanCanBeydili
26
+ - Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
27
+ - Instagram: https://www.instagram.com/canbeydilj
28
+ - Contact: tchasancan@gmail.com
13
29
  """
14
30
 
15
31
  import numpy as np
@@ -22,7 +38,7 @@ from .data_operations import normalization, non_neg_normalization
22
38
  from .ui import loading_bars, initialize_loading_bar
23
39
  from .activation_functions import apply_activation, all_activations
24
40
 
25
- def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons=None, activation_functions=None, dtype=np.float32):
41
+ def define_genomes(input_shape, output_shape, population_size, neurons=[], activation_functions=[], dtype=np.float32):
26
42
  """
27
43
  Initializes a population of genomes, where each genome is represented by a set of weights
28
44
  and an associated activation function. Each genome is created with random weights and activation
@@ -36,17 +52,15 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
36
52
 
37
53
  population_size (int): The number of genomes (individuals) in the population.
38
54
 
39
- hidden (int, optional): If you dont want train PLAN model this parameter represents a hidden layer count for MLP model. Default: 0 (PLAN)
55
+ neurons (list[int], optional): If you dont want train PLAN model this parameter represents neuron count of each hidden layer for MLP. Default: [] (PLAN)
40
56
 
41
- neurons (list[int], optional): If you dont want train PLAN model this parameter represents neuron count of each hidden layer for MLP. Default: None (PLAN)
42
-
43
- activation_functions (list[str], optional): If you dont want train PLAN model this parameter represents activation function of each hidden layer for MLP. Default: None (PLAN) NOTE: THIS EFFECTS HIDDEN LAYERS OUTPUT. NOT OUTPUT LAYER!
57
+ activation_functions (list[str], optional): If you dont want train PLAN model this parameter represents activation function of each hidden layer for MLP. Default: [] (PLAN) NOTE: THIS EFFECTS HIDDEN LAYERS OUTPUT. NOT OUTPUT LAYER!
44
58
 
45
59
  dtype (numpy.dtype): Data type for the arrays. np.float32 by default. Example: np.float64 or np.float16.
46
60
 
47
61
  Returns:
48
62
  tuple: A tuple containing:
49
- - population_weights (numpy.ndarray): A 2D numpy array of shape (population_size, output_shape, input_shape) representing the
63
+ - population_weights (numpy.ndarray[numpy.ndarray]): representing the
50
64
  weight matrices for each genome.
51
65
  - population_activations (list): A list of activation functions applied to each genome.
52
66
 
@@ -56,6 +70,9 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
56
70
  The weights for each genome are then modified by applying the corresponding activation function
57
71
  and normalized using the `normalization()` function. (Max abs normalization.)
58
72
  """
73
+
74
+ hidden = len(neurons)
75
+
59
76
  if hidden > 0:
60
77
  population_weights = np.empty((population_size, hidden + 1), dtype=object)
61
78
  population_activations = [[0] * (hidden) for _ in range(population_size)]
@@ -112,7 +129,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
112
129
 
113
130
 
114
131
  def evolver(weights,
115
- activation_potentiations,
132
+ activations,
116
133
  what_gen,
117
134
  fitness,
118
135
  weight_evolve=True,
@@ -148,7 +165,7 @@ def evolver(weights,
148
165
  weights (numpy.ndarray): Array of weights for each genome.
149
166
  (first returned value of define_genomes function)
150
167
 
151
- activation_potentiations (list[str]): A list of activation functions for each genome.
168
+ activations (list[str]): A list of activation functions for each genome.
152
169
  (second returned value of define_genomes function) NOTE!: 'activation potentiations' for PLAN 'activation functions' for MLP.
153
170
 
154
171
  what_gen (int): The current generation number, used for informational purposes or logging.
@@ -242,7 +259,7 @@ def evolver(weights,
242
259
  tuple: A tuple containing:
243
260
  - weights (numpy.ndarray): The updated weights for the population after selection, crossover, and mutation.
244
261
  The shape is (population_size, output_shape, input_shape).
245
- - activation_potentiations (list): The updated list of activation functions for the population.
262
+ - activations (list): The updated list of activation functions for the population.
246
263
 
247
264
  Notes:
248
265
  - **Selection Process**:
@@ -263,7 +280,7 @@ def evolver(weights,
263
280
 
264
281
  Example:
265
282
  ```python
266
- weights, activation_potentiations = planeat.evolver(weights, activation_potentiations, 1, fitness, show_info=True, strategy='normal_selective', policy='aggressive')
283
+ weights, activations = ene.evolver(weights, activations, 1, fitness, show_info=True, strategy='normal_selective', policy='aggressive')
267
284
  ```
268
285
 
269
286
  - The function returns the updated weights and activations after processing based on the chosen strategy, policy, and mutation parameters.
@@ -327,7 +344,7 @@ def evolver(weights,
327
344
  fitness = fitness[sort_indices]
328
345
  weights = weights[sort_indices]
329
346
 
330
- activation_potentiations = [activation_potentiations[i] for i in sort_indices]
347
+ activations = [activations[i] for i in sort_indices]
331
348
 
332
349
  ### GENOMES ARE DIVIDED INTO TWO GROUPS: GOOD GENOMES AND BAD GENOMES:
333
350
 
@@ -335,8 +352,8 @@ def evolver(weights,
335
352
  bad_weights = weights[:slice_center]
336
353
  best_weight = np.copy(good_weights[-1]) if is_mlp is False else copy.deepcopy(good_weights[-1])
337
354
 
338
- good_activations = list(activation_potentiations[slice_center:])
339
- bad_activations = list(activation_potentiations[:slice_center])
355
+ good_activations = list(activations[slice_center:])
356
+ bad_activations = list(activations[:slice_center])
340
357
  best_activations = good_activations[-1].copy() if isinstance(good_activations[-1], list) else good_activations[-1]
341
358
 
342
359
 
@@ -469,11 +486,11 @@ def evolver(weights,
469
486
  else:
470
487
  weights = np.vstack((child_W, mutated_W), dtype=dtype)
471
488
 
472
- activation_potentiations = child_act + mutated_act
489
+ activations = child_act + mutated_act
473
490
 
474
491
  if save_best_genome:
475
492
  weights[0] = best_weight
476
- activation_potentiations[0] = best_activations
493
+ activations[0] = best_activations
477
494
 
478
495
  ### INFO PRINTING CONSOLE
479
496
 
@@ -497,7 +514,7 @@ def evolver(weights,
497
514
  print(" ACTIVATION SELECTION THRESHOLD:", str(activation_selection_threshold))
498
515
  print(" ACTIVATION SELECTION ADD PROB: ", str(activation_selection_add_prob))
499
516
  print(" ACTIVATION SELECTION CHANGE PROB: ", str(activation_selection_change_prob))
500
- print(" FITNESS BIAS: ", str(fitness_bias) + '\n')
517
+ print(" FITNESS BIAS: ", str(fitness_bias))
501
518
  print(" SAVE BEST GENOME: ", str(save_best_genome) + '\n')
502
519
 
503
520
 
@@ -506,15 +523,16 @@ def evolver(weights,
506
523
  print(" MEAN FITNESS: ", str(round(np.mean(fitness), 2)))
507
524
  print(" MIN FITNESS: ", str(round(min(fitness), 2)) + '\n')
508
525
 
526
+ print(" BEST GENOME ACTIVATION LENGTH: ", str(len(best_activations)))
509
527
  print(" PREVIOUS BEST GENOME ACTIVATION LENGTH: ", str(len(best_activations)))
510
- print(" PREVIOUS BEST GENOME INDEX: ", str(previous_best_genome_index))
528
+ print(" PREVIOUS BEST GENOME INDEX: ", str(previous_best_genome_index) + '\n')
511
529
 
512
530
  if weight_evolve is False: weights = origin_weights
513
531
 
514
- return weights, activation_potentiations
532
+ return weights, activations
515
533
 
516
534
 
517
- def evaluate(Input, weights, activation_potentiations, is_mlp=False):
535
+ def evaluate(Input, weights, activations, is_mlp=False):
518
536
  """
519
537
  Evaluates the performance of a population of genomes, applying different activation functions
520
538
  and weights depending on whether reinforcement learning mode is enabled or not.
@@ -524,7 +542,7 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
524
542
  a genome (A list of input features for each genome, or a single set of input features for one genome).
525
543
  weights (list or numpy.ndarray): A list or 2D numpy array of weights corresponding to each genome
526
544
  in `x_population`. This determines the strength of connections.
527
- activation_potentiations (list or str): A list where each entry represents an activation function
545
+ activations (list or str): A list where each entry represents an activation function
528
546
  or a potentiation strategy applied to each genome. If only one
529
547
  activation function is used, this can be a single string.
530
548
  is_mlp (bool, optional): Evaluate PLAN model or MLP model ? Default: False (PLAN)
@@ -535,7 +553,7 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
535
553
 
536
554
  Example:
537
555
  ```python
538
- outputs = evaluate(Input, weights, activation_potentiations)
556
+ outputs = evaluate(Input, weights, activations)
539
557
  ```
540
558
 
541
559
  - The function returns a list of outputs after processing the population, where each element corresponds to
@@ -543,16 +561,16 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
543
561
  """
544
562
  ### THE OUTPUTS ARE RETURNED, WHERE EACH GENOME'S OUTPUT MATCHES ITS INDEX:
545
563
 
546
- if isinstance(activation_potentiations, str):
547
- activation_potentiations = [activation_potentiations]
548
- elif isinstance(activation_potentiations, list):
549
- activation_potentiations = [item if isinstance(item, list) or isinstance(item, str) else [item] for item in activation_potentiations]
564
+ if isinstance(activations, str):
565
+ activations = [activations]
566
+ elif isinstance(activations, list):
567
+ activations = [item if isinstance(item, list) or isinstance(item, str) else [item] for item in activations]
550
568
 
551
569
 
552
570
  if is_mlp:
553
571
  layer = Input
554
572
  for i in range(len(weights)):
555
- if i != len(weights) - 1 and i != 0: layer = apply_activation(layer, activation_potentiations[i])
573
+ if i != len(weights) - 1 and i != 0: layer = apply_activation(layer, activations[i])
556
574
 
557
575
  layer = layer @ weights[i].T
558
576
 
@@ -560,7 +578,7 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
560
578
 
561
579
  else:
562
580
 
563
- Input = apply_activation(Input, activation_potentiations)
581
+ Input = apply_activation(Input, activations)
564
582
  result = Input @ weights.T
565
583
 
566
584
  return result
@@ -1,15 +1,31 @@
1
1
  """
2
- MAIN MODULE FOR PLANEAT
2
+
3
+
4
+ ENE (Eugenic NeuroEvolution) on CUDA
5
+ ======================================
6
+
7
+ This module contains all the functions necessary for implementing and testing the ENE (Eugenic NeuroEvolution) algorithm on CUDA GPU.
8
+ For more information about the ENE algorithm: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PLAN/PLAN.pdf
9
+
10
+ Module functions:
11
+ -----------------
12
+ - evolver()
13
+ - define_genomes()
14
+ - evaluate()
15
+ - cross_over()
16
+ - mutation()
17
+ - dominant_parent_selection()
18
+ - second_parent_selection()
3
19
 
4
20
  Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
5
21
 
6
22
  PyerualJetwork document: https://github.com/HCB06/Anaplan/blob/main/Welcome_to_Anaplan/ANAPLAN_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
7
23
 
8
- @author: Hasan Can Beydili
9
- @YouTube: https://www.youtube.com/@HasanCanBeydili
10
- @Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
11
- @Instagram: https://www.instagram.com/canbeydilj
12
- @contact: tchasancan@gmail.com
24
+ - Author: Hasan Can Beydili
25
+ - YouTube: https://www.youtube.com/@HasanCanBeydili
26
+ - Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
27
+ - Instagram: https://www.instagram.com/canbeydilj
28
+ - Contact: tchasancan@gmail.com
13
29
  """
14
30
 
15
31
  import cupy as cp
@@ -23,7 +39,7 @@ from .data_operations_cuda import normalization, non_neg_normalization
23
39
  from .ui import loading_bars, initialize_loading_bar
24
40
  from .activation_functions_cuda import apply_activation, all_activations
25
41
 
26
- def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons=None, activation_functions=None, dtype=cp.float32):
42
+ def define_genomes(input_shape, output_shape, population_size, neurons=[], activation_functions=[], dtype=cp.float32):
27
43
  """
28
44
  Initializes a population of genomes, where each genome is represented by a set of weights
29
45
  and an associated activation function. Each genome is created with random weights and activation
@@ -36,8 +52,6 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
36
52
  output_shape (int): The number of output features for the neural network.
37
53
 
38
54
  population_size (int): The number of genomes (individuals) in the population.
39
-
40
- hidden (int, optional): If you dont want train PLAN model this parameter represents a hidden layer count for MLP model. Default: 0 (PLAN)
41
55
 
42
56
  neurons (list[int], optional): If you dont want train PLAN model this parameter represents neuron count of each hidden layer for MLP. Default: None (PLAN)
43
57
 
@@ -47,7 +61,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
47
61
 
48
62
  Returns:
49
63
  tuple: A tuple containing:
50
- - population_weights (cupy.ndarray): A 2D numpy array of shape (population_size, output_shape, input_shape) representing the
64
+ - population_weights (list[cupy.ndarray]): representing the
51
65
  weight matrices for each genome.
52
66
  - population_activations (list): A list of activation functions applied to each genome.
53
67
 
@@ -57,6 +71,9 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
57
71
  The weights for each genome are then modified by applying the corresponding activation function
58
72
  and normalized using the `normalization()` function. (Max abs normalization.)
59
73
  """
74
+
75
+ hidden = len(neurons)
76
+
60
77
  if hidden > 0:
61
78
  population_weights = [[0] * (hidden + 1) for _ in range(population_size)]
62
79
  population_activations = [[0] * (hidden) for _ in range(population_size)]
@@ -112,7 +129,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
112
129
  return cp.array(population_weights, dtype=dtype), population_activations
113
130
 
114
131
  def evolver(weights,
115
- activation_potentiations,
132
+ activations,
116
133
  what_gen,
117
134
  fitness,
118
135
  weight_evolve=True,
@@ -148,7 +165,7 @@ def evolver(weights,
148
165
  weights (cupy.ndarray): Array of weights for each genome.
149
166
  (first returned value of define_genomes function)
150
167
 
151
- activation_potentiations (list[str]): A list of activation functions for each genome.
168
+ activations (list[str]): A list of activation functions for each genome.
152
169
  (second returned value of define_genomes function) NOTE!: 'activation potentiations' for PLAN 'activation functions' for MLP.
153
170
 
154
171
  what_gen (int): The current generation number, used for informational purposes or logging.
@@ -242,7 +259,7 @@ def evolver(weights,
242
259
  tuple: A tuple containing:
243
260
  - weights (numpy.ndarray): The updated weights for the population after selection, crossover, and mutation.
244
261
  The shape is (population_size, output_shape, input_shape).
245
- - activation_potentiations (list): The updated list of activation functions for the population.
262
+ - activations (list): The updated list of activation functions for the population.
246
263
 
247
264
  Notes:
248
265
  - **Selection Process**:
@@ -263,7 +280,7 @@ def evolver(weights,
263
280
 
264
281
  Example:
265
282
  ```python
266
- weights, activation_potentiations = planeat_cuda.evolver(weights, activation_potentiations, 1, fitness, show_info=True, strategy='normal_selective', policy='aggressive')
283
+ weights, activations = ene_cuda.evolver(weights, activations, 1, fitness, show_info=True, strategy='normal_selective', policy='aggressive')
267
284
  ```
268
285
 
269
286
  - The function returns the updated weights and activations after processing based on the chosen strategy, policy, and mutation parameters.
@@ -336,7 +353,7 @@ def evolver(weights,
336
353
  fitness = fitness[sort_indices]
337
354
  weights = weights[sort_indices]
338
355
 
339
- activation_potentiations = [activation_potentiations[int(i)] for i in sort_indices]
356
+ activations = [activations[int(i)] for i in sort_indices]
340
357
 
341
358
  ### GENOMES ARE DIVIDED INTO TWO GROUPS: GOOD GENOMES AND BAD GENOMES:
342
359
 
@@ -344,8 +361,8 @@ def evolver(weights,
344
361
  bad_weights = weights[:slice_center]
345
362
  best_weight = cp.copy(good_weights[-1])
346
363
 
347
- good_activations = list(activation_potentiations[slice_center:])
348
- bad_activations = list(activation_potentiations[:slice_center])
364
+ good_activations = list(activations[slice_center:])
365
+ bad_activations = list(activations[:slice_center])
349
366
  best_activations = good_activations[-1].copy() if isinstance(good_activations[-1], list) else good_activations[-1]
350
367
 
351
368
 
@@ -487,11 +504,11 @@ def evolver(weights,
487
504
  else:
488
505
  weights = cp.vstack((child_W, mutated_W), dtype=dtype)
489
506
 
490
- activation_potentiations = child_act + mutated_act
507
+ activations = child_act + mutated_act
491
508
 
492
509
  if save_best_genome:
493
510
  weights[0] = best_weight
494
- activation_potentiations[0] = best_activations
511
+ activations[0] = best_activations
495
512
 
496
513
  ### INFO PRINTING CONSOLE
497
514
 
@@ -515,7 +532,7 @@ def evolver(weights,
515
532
  print(" ACTIVATION SELECTION THRESHOLD:", str(activation_selection_threshold))
516
533
  print(" ACTIVATION SELECTION ADD PROB: ", str(activation_selection_add_prob))
517
534
  print(" ACTIVATION SELECTION CHANGE PROB: ", str(activation_selection_change_prob))
518
- print(" FITNESS BIAS: ", str(fitness_bias) + '\n')
535
+ print(" FITNESS BIAS: ", str(fitness_bias))
519
536
  print(" SAVE BEST GENOME: ", str(save_best_genome) + '\n')
520
537
 
521
538
  print("*** Performance ***")
@@ -525,14 +542,14 @@ def evolver(weights,
525
542
 
526
543
  print(" BEST GENOME ACTIVATION LENGTH: ", str(len(best_activations)))
527
544
  print(" PREVIOUS BEST GENOME ACTIVATION LENGTH: ", str(len(best_activations)))
528
- print(" PREVIOUS BEST GENOME INDEX: ", str(previous_best_genome_index))
545
+ print(" PREVIOUS BEST GENOME INDEX: ", str(previous_best_genome_index) + '\n')
529
546
 
530
547
  if weight_evolve is False: weights = origin_weights
531
548
 
532
- return weights, activation_potentiations
549
+ return weights, activations
533
550
 
534
551
 
535
- def evaluate(Input, weights, activation_potentiations, is_mlp=False):
552
+ def evaluate(Input, weights, activations, is_mlp=False):
536
553
  """
537
554
  Evaluates the performance of a population of genomes, applying different activation functions
538
555
  and weights depending on whether reinforcement learning mode is enabled or not.
@@ -544,7 +561,7 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
544
561
  weights (list or cupy.ndarray): A list or 2D numpy array of weights corresponding to each genome
545
562
  in `x_population`. This determines the strength of connections.
546
563
 
547
- activation_potentiations (list or str): A list where each entry represents an activation function
564
+ activations (list or str): A list where each entry represents an activation function
548
565
  or a potentiation strategy applied to each genome. If only one
549
566
  activation function is used, this can be a single string.
550
567
  is_mlp (bool, optional): Evaluate PLAN model or MLP model ? Default: False (PLAN)
@@ -555,7 +572,7 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
555
572
 
556
573
  Example:
557
574
  ```python
558
- outputs = evaluate(Input, weights, activation_potentiations)
575
+ outputs = evaluate(Input, weights, activations)
559
576
  ```
560
577
 
561
578
  - The function returns a list of outputs after processing the population, where each element corresponds to
@@ -563,23 +580,23 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
563
580
  """
564
581
  ### THE OUTPUTS ARE RETURNED WHERE EACH GENOME'S OUTPUT MATCHES ITS INDEX:
565
582
 
566
- if isinstance(activation_potentiations, str):
567
- activation_potentiations = [activation_potentiations]
583
+ if isinstance(activations, str):
584
+ activations = [activations]
568
585
  else:
569
- activation_potentiations = [item if isinstance(item, list) else [item] for item in activation_potentiations]
586
+ activations = [item if isinstance(item, list) else [item] for item in activations]
570
587
 
571
588
  if is_mlp:
572
589
 
573
590
  layer = Input
574
591
  for i in range(len(weights)):
575
- if i != len(weights) - 1: layer = apply_activation(layer, activation_potentiations[i])
592
+ if i != len(weights) - 1: layer = apply_activation(layer, activations[i])
576
593
  layer = layer @ weights[i].T
577
594
 
578
595
  return layer
579
596
 
580
597
  else:
581
598
 
582
- Input = apply_activation(Input, activation_potentiations)
599
+ Input = apply_activation(Input, activations)
583
600
  result = Input @ weights.T
584
601
 
585
602
  return result
pyerualjetwork/help.py CHANGED
@@ -12,6 +12,6 @@ def activation_potentiation():
12
12
  def docs_and_examples():
13
13
 
14
14
  print('PLAN document: https://github.com/HCB06/Anaplan/tree/main/Welcome_to_PLAN\n')
15
- print('PLAN examples: https://github.com/HCB06/Anaplan/tree/main/Welcome_to_Anaplan/ExampleCodes\n')
16
- print('PLANEAT examples: https://github.com/HCB06/Anaplan/tree/main/Welcome_to_Anaplan/ExampleCodes/PLANEAT\n')
15
+ print('PLAN examples: https://github.com/HCB06/Anaplan/tree/main/Welcome_to_PyerualJetwork/ExampleCodes\n')
16
+ print('PLANEAT examples: https://github.com/HCB06/Anaplan/tree/main/Welcome_to_PyerualJetwork/ExampleCodes/ENE\n')
17
17
  print('Anaplan document and examples: https://github.com/HCB06/Anaplan/tree/main/Welcome_to_Anaplan')
@@ -1,3 +1,29 @@
1
+ """
2
+
3
+
4
+ Memory Operations
5
+ =================
6
+ This module hosts functions for managing all operational processes related to memory management,
7
+ including transferring data between CPU and GPU memory and retrieving memory information.
8
+
9
+ Module functions:
10
+ -----------------
11
+ - get_available_cpu_memory()
12
+ - transfer_to_cpu()
13
+ - transfer_to_gpu()
14
+ - optimize_labels()
15
+
16
+ Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
17
+
18
+ PyerualJetwork document: https://github.com/HCB06/Anaplan/blob/main/Welcome_to_Anaplan/ANAPLAN_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
19
+
20
+ - Author: Hasan Can Beydili
21
+ - YouTube: https://www.youtube.com/@HasanCanBeydili
22
+ - Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
23
+ - Instagram: https://www.instagram.com/canbeydilj
24
+ - Contact: tchasancan@gmail.com
25
+ """
26
+
1
27
  import psutil
2
28
  import numpy as np
3
29
  import cupy as cp