pyerualjetwork 4.4__py3-none-any.whl → 4.5.1__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.
pyerualjetwork/planeat.py CHANGED
@@ -17,7 +17,7 @@ import random
17
17
  import math
18
18
 
19
19
  ### LIBRARY IMPORTS ###
20
- from .data_operations import normalization
20
+ from .data_operations import normalization, non_neg_normalization
21
21
  from .ui import loading_bars, initialize_loading_bar
22
22
  from .activation_functions import apply_activation, all_activations
23
23
 
@@ -35,7 +35,7 @@ def define_genomes(input_shape, output_shape, population_size, dtype=np.float32)
35
35
 
36
36
  population_size (int): The number of genomes (individuals) in the population.
37
37
 
38
- dtype (numpy.dtype): Data type for the arrays. np.float32 by default. Example: np.float64 or np.float16. [fp32 for balanced devices, fp64 for strong devices, fp16 for weak devices: not reccomended!] (optional)
38
+ dtype (numpy.dtype): Data type for the arrays. np.float32 by default. Example: np.float64 or np.float16.
39
39
 
40
40
  Returns:
41
41
  tuple: A tuple containing:
@@ -291,7 +291,7 @@ def evolver(weights,
291
291
  bar_format = loading_bars()[0]
292
292
 
293
293
  if bar_status: progress = initialize_loading_bar(len(bad_weights), desc="GENERATION: " + str(what_gen), bar_format=bar_format, ncols=50)
294
- normalized_fitness = normalization(fitness, dtype=dtype)
294
+ normalized_fitness = non_neg_normalization(fitness, dtype=dtype)
295
295
 
296
296
  best_fitness = normalized_fitness[-1]
297
297
  epsilon = np.finfo(float).eps
@@ -708,28 +708,18 @@ def mutation(weight,
708
708
 
709
709
  if potential_weight_mutation > weight_mutate_prob:
710
710
 
711
- start = 0
712
- row_end = weight.shape[0]
713
- col_end = weight.shape[1]
714
-
715
- max_threshold = row_end * col_end
716
-
717
- threshold = weight_mutate_threshold * (genome_fitness + epsilon)
718
- new_threshold = threshold
719
-
720
- for _ in range(max_threshold):
711
+ row_end, col_end = weight.shape
712
+ max_threshold = row_end * col_end
713
+ threshold = weight_mutate_threshold / (genome_fitness + epsilon)
714
+
715
+ n_mutations = min(int(threshold), max_threshold)
716
+
717
+ row_indices = np.random.randint(0, row_end, size=n_mutations)
718
+ col_indices = np.random.randint(0, col_end, size=n_mutations)
721
719
 
722
- selected_row = int(random.uniform(start, row_end))
723
- selected_col = int(random.uniform(start, col_end))
724
-
725
- weight[selected_row, selected_col] = random.uniform(-1, 1)
726
- new_threshold += threshold
727
-
728
- if max_threshold > new_threshold:
729
- pass
720
+ new_values = np.random.uniform(-1, 1, size=n_mutations)
730
721
 
731
- else:
732
- break
722
+ weight[row_indices, col_indices] = new_values
733
723
 
734
724
  activation_mutate_prob = 1 - activation_mutate_prob
735
725
  potential_activation_mutation = random.uniform(0, 1)
@@ -19,7 +19,7 @@ import math
19
19
 
20
20
 
21
21
  ### LIBRARY IMPORTS ###
22
- from .data_operations_cuda import normalization
22
+ from .data_operations_cuda import normalization, non_neg_normalization
23
23
  from .ui import loading_bars, initialize_loading_bar
24
24
  from .activation_functions_cuda import apply_activation, all_activations
25
25
 
@@ -37,7 +37,7 @@ def define_genomes(input_shape, output_shape, population_size, dtype=cp.float32)
37
37
 
38
38
  population_size (int): The number of genomes (individuals) in the population.
39
39
 
40
- dtype (cupy.dtype): Data type for the arrays. np.float32 by default. Example: cp.float64 or cp.float16. [fp32 for balanced devices, fp64 for strong devices, fp16 for weak devices: not reccomended!] (optional)
40
+ dtype (cupy.dtype): Data type for the arrays. np.float32 by default. Example: cp.float64 or cp.float16.
41
41
 
42
42
  Returns:
43
43
  tuple: A tuple containing:
@@ -97,7 +97,7 @@ def evolver(weights,
97
97
  weight_mutate_prob=1,
98
98
  dtype=cp.float32):
99
99
  """
100
- Applies the evolving process of a population of genomes using selection, crossover, mutation, and activation function potentiation.
100
+ Applies the evolving process of a population of genomes using selection, crossover, mutation, and activation function potentiation.
101
101
  The function modifies the population's weights and activation functions based on a specified policy, mutation probabilities, and strategy.
102
102
 
103
103
  'selection' args effects cross-over.
@@ -292,7 +292,7 @@ def evolver(weights,
292
292
  bar_format = loading_bars()[0]
293
293
 
294
294
  if bar_status: progress = initialize_loading_bar(len(bad_weights), desc="GENERATION: " + str(what_gen), bar_format=bar_format, ncols=50)
295
- normalized_fitness = normalization(fitness, dtype=dtype)
295
+ normalized_fitness = non_neg_normalization(fitness, dtype=dtype)
296
296
 
297
297
  best_fitness = normalized_fitness[-1]
298
298
  epsilon = cp.finfo(float).eps
@@ -709,28 +709,18 @@ def mutation(weight,
709
709
 
710
710
  if potential_weight_mutation > weight_mutate_prob:
711
711
 
712
- start = 0
713
- row_end = weight.shape[0]
714
- col_end = weight.shape[1]
715
-
716
- max_threshold = row_end * col_end
717
-
718
- threshold = weight_mutate_threshold * (genome_fitness + epsilon)
719
- new_threshold = threshold
720
-
721
- for _ in range(max_threshold):
712
+ row_end, col_end = weight.shape
713
+ max_threshold = row_end * col_end
714
+ threshold = weight_mutate_threshold / (genome_fitness + epsilon)
715
+
716
+ n_mutations = min(int(threshold), max_threshold)
717
+
718
+ row_indices = cp.random.randint(0, row_end, size=n_mutations)
719
+ col_indices = cp.random.randint(0, col_end, size=n_mutations)
722
720
 
723
- selected_row = int(random.uniform(start, row_end))
724
- selected_col = int(random.uniform(start, col_end))
725
-
726
- weight[selected_row, selected_col] = random.uniform(-1, 1)
727
- new_threshold += threshold
728
-
729
- if max_threshold > new_threshold:
730
- pass
721
+ new_values = cp.random.uniform(-1, 1, size=n_mutations)
731
722
 
732
- else:
733
- break
723
+ weight[row_indices, col_indices] = new_values
734
724
 
735
725
  activation_mutate_prob = 1 - activation_mutate_prob
736
726
  potential_activation_mutation = random.uniform(0, 1)
@@ -9,27 +9,27 @@ def draw_neural_web(W, ax, G, return_objs=False):
9
9
  """
10
10
  Visualizes a neural web by drawing the neural network structure.
11
11
 
12
- Parameters:
13
- W : numpy.ndarray
14
- A 2D array representing the connection weights of the neural network.
15
- ax : matplotlib.axes.Axes
16
- The matplotlib axes where the graph will be drawn.
17
- G : networkx.Graph
18
- The NetworkX graph representing the neural network structure.
19
- return_objs : bool, optional
20
- If True, returns the drawn objects (nodes and edges). Default is False.
12
+ Args:
13
+ W : numpy.ndarray
14
+ A 2D array representing the connection weights of the neural network.
15
+ ax : matplotlib.axes.Axes
16
+ The matplotlib axes where the graph will be drawn.
17
+ G : networkx.Graph
18
+ The NetworkX graph representing the neural network structure.
19
+ return_objs : bool, optional
20
+ If True, returns the drawn objects (nodes and edges). Default is False.
21
21
 
22
22
  Returns:
23
- art1 : matplotlib.collections.PathCollection or None
24
- Returns the node collection if return_objs is True; otherwise, returns None.
25
- art2 : matplotlib.collections.LineCollection or None
26
- Returns the edge collection if return_objs is True; otherwise, returns None.
27
- art3 : matplotlib.collections.TextCollection or None
28
- Returns the label collection if return_objs is True; otherwise, returns None.
23
+ art1 : matplotlib.collections.PathCollection or None
24
+ Returns the node collection if return_objs is True; otherwise, returns None.
25
+ art2 : matplotlib.collections.LineCollection or None
26
+ Returns the edge collection if return_objs is True; otherwise, returns None.
27
+ art3 : matplotlib.collections.TextCollection or None
28
+ Returns the label collection if return_objs is True; otherwise, returns None.
29
29
 
30
30
  Example:
31
- art1, art2, art3 = draw_neural_web(W, ax, G, return_objs=True)
32
- plt.show()
31
+ art1, art2, art3 = draw_neural_web(W, ax, G, return_objs=True)
32
+ plt.show()
33
33
  """
34
34
 
35
35
  for i in range(W.shape[0]):
@@ -9,27 +9,27 @@ def draw_neural_web(W, ax, G, return_objs=False):
9
9
  """
10
10
  Visualizes a neural web by drawing the neural network structure.
11
11
 
12
- Parameters:
13
- W : numpy.ndarray
14
- A 2D array representing the connection weights of the neural network.
15
- ax : matplotlib.axes.Axes
16
- The matplotlib axes where the graph will be drawn.
17
- G : networkx.Graph
18
- The NetworkX graph representing the neural network structure.
19
- return_objs : bool, optional
20
- If True, returns the drawn objects (nodes and edges). Default is False.
12
+ Args:
13
+ W : numpy.ndarray
14
+ A 2D array representing the connection weights of the neural network.
15
+ ax : matplotlib.axes.Axes
16
+ The matplotlib axes where the graph will be drawn.
17
+ G : networkx.Graph
18
+ The NetworkX graph representing the neural network structure.
19
+ return_objs : bool, optional
20
+ If True, returns the drawn objects (nodes and edges). Default is False.
21
21
 
22
22
  Returns:
23
- art1 : matplotlib.collections.PathCollection or None
24
- Returns the node collection if return_objs is True; otherwise, returns None.
25
- art2 : matplotlib.collections.LineCollection or None
26
- Returns the edge collection if return_objs is True; otherwise, returns None.
27
- art3 : matplotlib.collections.TextCollection or None
28
- Returns the label collection if return_objs is True; otherwise, returns None.
23
+ art1 : matplotlib.collections.PathCollection or None
24
+ Returns the node collection if return_objs is True; otherwise, returns None.
25
+ art2 : matplotlib.collections.LineCollection or None
26
+ Returns the edge collection if return_objs is True; otherwise, returns None.
27
+ art3 : matplotlib.collections.TextCollection or None
28
+ Returns the label collection if return_objs is True; otherwise, returns None.
29
29
 
30
30
  Example:
31
- art1, art2, art3 = draw_neural_web(W, ax, G, return_objs=True)
32
- plt.show()
31
+ art1, art2, art3 = draw_neural_web(W, ax, G, return_objs=True)
32
+ plt.show()
33
33
  """
34
34
  W = W.get()
35
35
  for i in range(W.shape[0]):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.4
3
+ Version: 4.5.1
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
@@ -0,0 +1,25 @@
1
+ pyerualjetwork/__init__.py,sha256=Oe1PUj-kEsIW73oaiAxac3x_QQxSAFhOpUacNgzc6gs,1279
2
+ pyerualjetwork/activation_functions.py,sha256=Ms0AGBqkJuCA42ht64MSQnO54Td_1eDGquedpoBDVbc,7642
3
+ pyerualjetwork/activation_functions_cuda.py,sha256=5y1Ti3GDfDteQDCUmODwe7tAyDAUlDTKmIikChQ8d6g,7772
4
+ pyerualjetwork/data_operations.py,sha256=SOPcuCUedAVKLZ10q4uX8XVgtFAgQ2gz6efVHR6ctw0,15166
5
+ pyerualjetwork/data_operations_cuda.py,sha256=X0rUCxehqyVknjBToJ0zXCTGQwlAA7GEVAcqQ-YJYfQ,17267
6
+ pyerualjetwork/fitness_functions.py,sha256=urRdeMvUhNgWxD4ZGHCRdQlIf9cTWYMvF3_aVBojRqY,1235
7
+ pyerualjetwork/help.py,sha256=nQ_YbYA2RtuafhuvkreNpX0WWL1I_nzlelwCtvei0_Y,775
8
+ pyerualjetwork/loss_functions.py,sha256=6PyBI232SQRGuFnG3LDGvnv_PUdWzT2_2mUODJiejGI,618
9
+ pyerualjetwork/loss_functions_cuda.py,sha256=C93IZJcrOpT6HMK9x1O4AHJWXYTkN5WZiqdssPbvAPk,617
10
+ pyerualjetwork/memory_operations.py,sha256=0yCOHcgiNyF4ccMcRlL1Q9F_byG4nzjhmkbpXE_yU6E,13401
11
+ pyerualjetwork/metrics.py,sha256=q7MkhnZDRbCjFBDDfUgrl8lBYnUT_1ro1LxeBq105pI,6077
12
+ pyerualjetwork/metrics_cuda.py,sha256=73h9GC7XwmnFCVzFEEiPQfF8CwHIz2wsCbxpZrJtYgw,5061
13
+ pyerualjetwork/model_operations.py,sha256=BLRL_5s_KSs8iCiLsEwWvhRcGiWCP_TD9lsjYWM7Zek,12746
14
+ pyerualjetwork/model_operations_cuda.py,sha256=b3Bkobbrhq28AmYZ0vGxf2Hf8V2LPvoiM0xaPAApqec,13254
15
+ pyerualjetwork/plan.py,sha256=UyIvPmvHCHwczlc9KHolE4y6CPEeBfhnRN5yznSbnoM,23028
16
+ pyerualjetwork/plan_cuda.py,sha256=iteqgv7x9Z2Pj4vGOZs6HXS3r0bNaF_smr7ZXaOdRnw,23990
17
+ pyerualjetwork/planeat.py,sha256=_dnGRVBzdRUgvVCnHZ721tdXYV9PSvCz-aUnj--5VpU,38697
18
+ pyerualjetwork/planeat_cuda.py,sha256=CXBF4vsTZ-fE-3W8Zc6Zxe_oKuyJS02FaHsOzSwzLV8,38731
19
+ pyerualjetwork/ui.py,sha256=wu2BhU1k-w3Kcho5Jtq4SEKe68ftaUeRGneUOSCVDjU,575
20
+ pyerualjetwork/visualizations.py,sha256=utnX9zQhzmtvBJLOLNGm2jecVVk4zHXABQdjb0XzJac,28352
21
+ pyerualjetwork/visualizations_cuda.py,sha256=gnoaaazZ-nc9E1ImqXrZBRgQ4Rnpi2qh2yGJ2eLKMlE,28807
22
+ pyerualjetwork-4.5.1.dist-info/METADATA,sha256=xjGpEBnY_JunoNvXCbD1oJfdYL7Wvzj0Nt7oWj61gZg,7505
23
+ pyerualjetwork-4.5.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
+ pyerualjetwork-4.5.1.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
25
+ pyerualjetwork-4.5.1.dist-info/RECORD,,
@@ -1,25 +0,0 @@
1
- pyerualjetwork/__init__.py,sha256=FyN5mW58VZsm76E1zSzF5opP6gHodZnkhPYS17xv9jc,1277
2
- pyerualjetwork/activation_functions.py,sha256=Ms0AGBqkJuCA42ht64MSQnO54Td_1eDGquedpoBDVbc,7642
3
- pyerualjetwork/activation_functions_cuda.py,sha256=5y1Ti3GDfDteQDCUmODwe7tAyDAUlDTKmIikChQ8d6g,7772
4
- pyerualjetwork/data_operations.py,sha256=Flteouu6rfSo2uHMqBHuzO02dXmbNa-I5qWmUpGTZ5Y,14760
5
- pyerualjetwork/data_operations_cuda.py,sha256=ZcjmLXE1-HVwedextYdJZ1rgrns1OfSekzFpr1a9m6o,17625
6
- pyerualjetwork/fitness_functions.py,sha256=9ZtCasBVjk3qQldi2pIzV6c5hTBJJyGCU0eVhJsoxPo,1145
7
- pyerualjetwork/help.py,sha256=nQ_YbYA2RtuafhuvkreNpX0WWL1I_nzlelwCtvei0_Y,775
8
- pyerualjetwork/loss_functions.py,sha256=6PyBI232SQRGuFnG3LDGvnv_PUdWzT2_2mUODJiejGI,618
9
- pyerualjetwork/loss_functions_cuda.py,sha256=C93IZJcrOpT6HMK9x1O4AHJWXYTkN5WZiqdssPbvAPk,617
10
- pyerualjetwork/memory_operations.py,sha256=I7QiZ--xSyRkFF0wcckPwZV7K9emEvyx5aJ3DiRHZFI,13468
11
- pyerualjetwork/metrics.py,sha256=q7MkhnZDRbCjFBDDfUgrl8lBYnUT_1ro1LxeBq105pI,6077
12
- pyerualjetwork/metrics_cuda.py,sha256=73h9GC7XwmnFCVzFEEiPQfF8CwHIz2wsCbxpZrJtYgw,5061
13
- pyerualjetwork/model_operations.py,sha256=MCSCNYiiICRVZITobtS3ZIWmH5Q9gjyELuH32sAdgg4,12649
14
- pyerualjetwork/model_operations_cuda.py,sha256=NT01BK5nrDYE7H1x3KnSI8gmx0QTGGB0mP_LqEb1uuU,13157
15
- pyerualjetwork/plan.py,sha256=VeoG3QU6vy9I7HG23aQS4qzo5_R-tAxwXdu0oT_2mBw,22973
16
- pyerualjetwork/plan_cuda.py,sha256=LKuNDDmUH_tcVvdBC29ASB6U2SKETC6lcWQiH-8vi1A,23965
17
- pyerualjetwork/planeat.py,sha256=oAu0a2rs6BQ2HUpLjKFR4m7xDbhUVOzLstop75u35Tg,38889
18
- pyerualjetwork/planeat_cuda.py,sha256=E_pJEsNKfiF97FvGZGSsxmdqzLAJub05enmneymozcg,38922
19
- pyerualjetwork/ui.py,sha256=wu2BhU1k-w3Kcho5Jtq4SEKe68ftaUeRGneUOSCVDjU,575
20
- pyerualjetwork/visualizations.py,sha256=1QSisYAaGnO5kug6qo1qOssTkQM-MgR7L8h4c3sczzU,28294
21
- pyerualjetwork/visualizations_cuda.py,sha256=PYRqj4QYUbuYMYcNwO8yaTPB-jK7E6kZHhTrAi0lwPU,28749
22
- pyerualjetwork-4.4.dist-info/METADATA,sha256=i89Z4ZNMY6mLus5DkDqYBXasOQaq33DAogrFR0dU0Fw,7503
23
- pyerualjetwork-4.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
- pyerualjetwork-4.4.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
25
- pyerualjetwork-4.4.dist-info/RECORD,,