pyerualjetwork 4.3.8.dev15__tar.gz → 4.3.9__tar.gz
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-4.3.8.dev15 → pyerualjetwork-4.3.9}/PKG-INFO +3 -19
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/README.md +2 -18
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork/__init__.py +1 -1
- pyerualjetwork-4.3.9/pyerualjetwork/fitness_functions.py +72 -0
- pyerualjetwork-4.3.9/pyerualjetwork/fitness_functions_cuda.py +85 -0
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/plan.py +118 -146
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/plan_cuda.py +111 -142
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/planeat.py +12 -10
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork/planeat_cuda.py +11 -47
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/visualizations.py +31 -28
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/visualizations_cuda.py +22 -24
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork.egg-info/PKG-INFO +3 -19
- pyerualjetwork-4.3.9/pyerualjetwork.egg-info/SOURCES.txt +27 -0
- pyerualjetwork-4.3.9/pyerualjetwork.egg-info/top_level.txt +1 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/setup.py +5 -2
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/activation_functions.py +0 -290
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/activation_functions_cuda.py +0 -340
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/data_operations_cuda.py +0 -461
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/loss_functions.py +0 -21
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/loss_functions_cuda.py +0 -21
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/model_operations.py +0 -408
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/model_operations_cuda.py +0 -421
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/plan.py +0 -627
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/plan_cuda.py +0 -648
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/planeat.py +0 -825
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/visualizations.py +0 -823
- pyerualjetwork-4.3.8.dev15/pyerualjetwork/visualizations_cuda.py +0 -825
- pyerualjetwork-4.3.8.dev15/pyerualjetwork.egg-info/SOURCES.txt +0 -48
- pyerualjetwork-4.3.8.dev15/pyerualjetwork.egg-info/top_level.txt +0 -2
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/__init__.py +0 -11
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/data_operations.py +0 -406
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/help.py +0 -17
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/loss_functions.py +0 -21
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/loss_functions_cuda.py +0 -21
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/memory_operations.py +0 -298
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/metrics.py +0 -190
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/metrics_cuda.py +0 -163
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/parallel.py +0 -118
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/planeat_cuda.py +0 -752
- pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner/ui.py +0 -22
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/activation_functions.py +0 -0
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/activation_functions_cuda.py +0 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork/data_operations.py +0 -0
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/data_operations_cuda.py +0 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork/help.py +0 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork/memory_operations.py +0 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork/metrics.py +0 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork/metrics_cuda.py +0 -0
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/model_operations.py +0 -0
- {pyerualjetwork-4.3.8.dev15/pyerualjetwork_afterburner → pyerualjetwork-4.3.9/pyerualjetwork}/model_operations_cuda.py +0 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork/ui.py +0 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/pyerualjetwork.egg-info/dependency_links.txt +0 -0
- {pyerualjetwork-4.3.8.dev15 → pyerualjetwork-4.3.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyerualjetwork
|
3
|
-
Version: 4.3.
|
3
|
+
Version: 4.3.9
|
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
|
@@ -25,8 +25,6 @@ GitHub Page: https://github.com/HCB06/PyerualJetwork
|
|
25
25
|
YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7HbsBpCx2VTJ4SK9wcPyse-EHw
|
26
26
|
|
27
27
|
pip install pyerualjetwork
|
28
|
-
|
29
|
-
'use this if your data small or memory management is a problem :'
|
30
28
|
|
31
29
|
from pyerualjetwork import plan
|
32
30
|
from pyerualjetwork import planeat
|
@@ -38,28 +36,14 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
38
36
|
from pyerualjetwork import data_operations_cuda
|
39
37
|
from pyerualjetwork import model_operations_cuda
|
40
38
|
|
41
|
-
'use this if your data large or memory management is not a problem : _afterburner package (afterburner package comes with powerful paralellism,
|
42
|
-
afterburner with cuda modules offers super-fast training but some memory managemant features and visualization features discarded.
|
43
|
-
Specially designed for LLM training and other massive model training)'
|
44
|
-
|
45
|
-
from pyerualjetwork_afterburner import plan
|
46
|
-
from pyerualjetwork_afterburner import planeat
|
47
|
-
from pyerualjetwork_afterburner import data_operations
|
48
|
-
from pyerualjetwork_afterburner import model_operations
|
49
|
-
|
50
|
-
from pyerualjetwork_afterburner import plan_cuda
|
51
|
-
from pyerualjetwork_afterburner import planeat_cuda
|
52
|
-
from pyerualjetwork_afterburner import data_operations_cuda
|
53
|
-
from pyerualjetwork_afterburner import model_operations_cuda
|
54
|
-
|
55
39
|
Optimized for Visual Studio Code
|
56
40
|
|
57
41
|
requires=[
|
58
42
|
'scipy==1.13.1',
|
59
43
|
'tqdm==4.66.4',
|
60
|
-
'seaborn==0.13.2',
|
61
44
|
'pandas==2.2.2',
|
62
45
|
'networkx==3.3',
|
46
|
+
'seaborn==0.13.2',
|
63
47
|
'numpy==1.26.4',
|
64
48
|
'matplotlib==3.9.0',
|
65
49
|
'colorama==0.4.6',
|
@@ -67,7 +51,7 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
67
51
|
'psutil==6.1.1'
|
68
52
|
]
|
69
53
|
|
70
|
-
matplotlib,
|
54
|
+
matplotlib, networkx (optional).
|
71
55
|
|
72
56
|
##############################
|
73
57
|
|
@@ -16,8 +16,6 @@ GitHub Page: https://github.com/HCB06/PyerualJetwork
|
|
16
16
|
YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7HbsBpCx2VTJ4SK9wcPyse-EHw
|
17
17
|
|
18
18
|
pip install pyerualjetwork
|
19
|
-
|
20
|
-
'use this if your data small or memory management is a problem :'
|
21
19
|
|
22
20
|
from pyerualjetwork import plan
|
23
21
|
from pyerualjetwork import planeat
|
@@ -29,28 +27,14 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
29
27
|
from pyerualjetwork import data_operations_cuda
|
30
28
|
from pyerualjetwork import model_operations_cuda
|
31
29
|
|
32
|
-
'use this if your data large or memory management is not a problem : _afterburner package (afterburner package comes with powerful paralellism,
|
33
|
-
afterburner with cuda modules offers super-fast training but some memory managemant features and visualization features discarded.
|
34
|
-
Specially designed for LLM training and other massive model training)'
|
35
|
-
|
36
|
-
from pyerualjetwork_afterburner import plan
|
37
|
-
from pyerualjetwork_afterburner import planeat
|
38
|
-
from pyerualjetwork_afterburner import data_operations
|
39
|
-
from pyerualjetwork_afterburner import model_operations
|
40
|
-
|
41
|
-
from pyerualjetwork_afterburner import plan_cuda
|
42
|
-
from pyerualjetwork_afterburner import planeat_cuda
|
43
|
-
from pyerualjetwork_afterburner import data_operations_cuda
|
44
|
-
from pyerualjetwork_afterburner import model_operations_cuda
|
45
|
-
|
46
30
|
Optimized for Visual Studio Code
|
47
31
|
|
48
32
|
requires=[
|
49
33
|
'scipy==1.13.1',
|
50
34
|
'tqdm==4.66.4',
|
51
|
-
'seaborn==0.13.2',
|
52
35
|
'pandas==2.2.2',
|
53
36
|
'networkx==3.3',
|
37
|
+
'seaborn==0.13.2',
|
54
38
|
'numpy==1.26.4',
|
55
39
|
'matplotlib==3.9.0',
|
56
40
|
'colorama==0.4.6',
|
@@ -58,7 +42,7 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
58
42
|
'psutil==6.1.1'
|
59
43
|
]
|
60
44
|
|
61
|
-
matplotlib,
|
45
|
+
matplotlib, networkx (optional).
|
62
46
|
|
63
47
|
##############################
|
64
48
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
__version__ = "4.3.
|
1
|
+
__version__ = "4.3.9"
|
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__):
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import numpy as np
|
2
|
+
from scipy.spatial.distance import pdist
|
3
|
+
|
4
|
+
def diversity_score(population):
|
5
|
+
"""
|
6
|
+
Calculates the diversity score of a population based on the
|
7
|
+
Euclidean distances between individuals in the population.
|
8
|
+
|
9
|
+
:param population: That calculates the diversity score of a population based on the Euclidean distances between
|
10
|
+
individuals in the population
|
11
|
+
:return: The function returns the diversity score,
|
12
|
+
which is a measure of how spread out or diverse the population is in terms of their characteristics.
|
13
|
+
"""
|
14
|
+
if len(population) < 2:
|
15
|
+
return 0
|
16
|
+
|
17
|
+
population = np.nan_to_num(population, nan=0.0)
|
18
|
+
|
19
|
+
distances = pdist(population, metric='euclidean')
|
20
|
+
distances = np.maximum(distances, 1e-10)
|
21
|
+
|
22
|
+
avg_distance = np.mean(distances)
|
23
|
+
if population.shape[1] == 0:
|
24
|
+
return 0
|
25
|
+
|
26
|
+
max_possible_distance = np.sqrt(population.shape[1])
|
27
|
+
max_possible_distance = max(max_possible_distance, 1e-10)
|
28
|
+
|
29
|
+
diversity = avg_distance / max_possible_distance
|
30
|
+
return diversity
|
31
|
+
|
32
|
+
def multi_head_fitness(y_true, y_pred, diversity_score, accuracy, alpha=2, beta=1.5, lambda_div=0.05):
|
33
|
+
"""
|
34
|
+
The function calculates a fitness score based on accuracy, margin loss, and diversity score using
|
35
|
+
specified parameters.
|
36
|
+
|
37
|
+
@param y_true The `y_true` parameter represents the true labels of the data points. It is an array
|
38
|
+
or list containing the actual labels of the data points.
|
39
|
+
@param y_pred The `y_pred` parameter in the `multi_head_fitness` function represents the
|
40
|
+
predicted values for a given dataset. It is a NumPy array containing the predicted values for each
|
41
|
+
sample in the dataset.
|
42
|
+
@param diversity_score The `diversity_score` parameter in the `multi_head_fitness` function
|
43
|
+
represents a measure of diversity in the predictions. It is used as a factor in calculating the
|
44
|
+
fitness of the model. The function combines accuracy, margin loss, and diversity score to evaluate
|
45
|
+
the overall performance of the model
|
46
|
+
@param accuracy Accuracy is a measure of the correct predictions made by a model. It is typically
|
47
|
+
calculated as the number of correct predictions divided by the total number of predictions. In the
|
48
|
+
context of the `multi_head_fitness` function, the accuracy parameter represents the accuracy
|
49
|
+
of the model's predictions.
|
50
|
+
@param alpha Alpha is a parameter that controls the impact of accuracy on the overall fitness score
|
51
|
+
in the multi_head_fitness function. It is used as an exponent to raise the accuracy value
|
52
|
+
to, influencing its contribution to the fitness calculation.
|
53
|
+
@param beta The `beta` parameter in the `multi_head_fitness` function is used as an exponent
|
54
|
+
in the fitness calculation formula. It controls the impact of the margin loss term on the overall
|
55
|
+
fitness value. A higher value of `beta` will amplify the effect of the margin loss term, making it
|
56
|
+
@param lambda_div The `lambda_div` parameter in the `multi_head_fitness` function represents
|
57
|
+
the weight given to the diversity score in calculating the fitness value. It is a hyperparameter
|
58
|
+
that controls the impact of diversity score on the overall fitness calculation. A higher value of
|
59
|
+
`lambda_div` will increase the importance
|
60
|
+
@return The function `multi_head_fitness` returns the fitness value calculated based on the
|
61
|
+
input parameters `y_true`, `y_pred`, `diversity_score`, `accuracy`, and optional parameters `alpha`,
|
62
|
+
`beta`, and `lambda_div`. The fitness value is computed using a formula that combines accuracy,
|
63
|
+
margin loss, and diversity score with specified weights and coefficients.
|
64
|
+
"""
|
65
|
+
incorrect = y_true != y_pred
|
66
|
+
margin_loss = np.abs(y_true[incorrect] - y_pred[incorrect]).mean() if np.any(incorrect) else 0
|
67
|
+
|
68
|
+
margin_loss = np.nan_to_num(margin_loss, nan=0.0)
|
69
|
+
accuracy = max(accuracy, 1e-10)
|
70
|
+
|
71
|
+
fitness = (accuracy ** alpha) * ((1 - margin_loss) ** beta) * (1 + lambda_div * diversity_score)
|
72
|
+
return fitness
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import cupy as cp
|
2
|
+
|
3
|
+
def cupy_pairwise_distances(X):
|
4
|
+
"""
|
5
|
+
Pairwise Euclidean distances
|
6
|
+
"""
|
7
|
+
r = cp.sum(X * X, 1)
|
8
|
+
r = r.reshape(-1, 1)
|
9
|
+
|
10
|
+
distances = cp.maximum(r - 2 * cp.dot(X, X.T) + r.T, 0.0)
|
11
|
+
|
12
|
+
triu_indices = cp.triu_indices(distances.shape[0], k=1)
|
13
|
+
return cp.sqrt(distances[triu_indices])
|
14
|
+
|
15
|
+
|
16
|
+
def diversity_score(population):
|
17
|
+
"""
|
18
|
+
Calculates the diversity score of a population based on the
|
19
|
+
Euclidean distances between individuals in the population.
|
20
|
+
|
21
|
+
:param population: That calculates the diversity score of a population based on the Euclidean distances between
|
22
|
+
individuals in the population
|
23
|
+
:return: The function returns the diversity score,
|
24
|
+
which is a measure of how spread out or diverse the population is in terms of their characteristics.
|
25
|
+
"""
|
26
|
+
if len(population) < 2:
|
27
|
+
return 0
|
28
|
+
|
29
|
+
population = cp.nan_to_num(population, nan=0.0)
|
30
|
+
|
31
|
+
distances = cupy_pairwise_distances(population)
|
32
|
+
distances = cp.maximum(distances, 1e-10)
|
33
|
+
|
34
|
+
avg_distance = cp.mean(distances)
|
35
|
+
if population.shape[1] == 0:
|
36
|
+
return 0
|
37
|
+
|
38
|
+
max_possible_distance = cp.sqrt(population.shape[1])
|
39
|
+
max_possible_distance = float(max(max_possible_distance, 1e-10))
|
40
|
+
|
41
|
+
diversity = float(avg_distance / max_possible_distance)
|
42
|
+
return diversity
|
43
|
+
|
44
|
+
|
45
|
+
def multi_head_fitness(y_true, y_pred, diversity_score, accuracy, alpha=2, beta=1.5, lambda_div=0.05):
|
46
|
+
"""
|
47
|
+
The function calculates a fitness score based on accuracy, margin loss, and diversity score using
|
48
|
+
specified parameters.
|
49
|
+
|
50
|
+
@param y_true The `y_true` parameter represents the true labels of the data points. It is an array
|
51
|
+
or list containing the actual labels of the data points.
|
52
|
+
@param y_pred The `y_pred` parameter in the `multi_head_fitness` function represents the
|
53
|
+
predicted values for a given dataset. It is a NumPy array containing the predicted values for each
|
54
|
+
sample in the dataset.
|
55
|
+
@param diversity_score The `diversity_score` parameter in the `multi_head_fitness` function
|
56
|
+
represents a measure of diversity in the predictions. It is used as a factor in calculating the
|
57
|
+
fitness of the model. The function combines accuracy, margin loss, and diversity score to evaluate
|
58
|
+
the overall performance of the model
|
59
|
+
@param accuracy Accuracy is a measure of the correct predictions made by a model. It is typically
|
60
|
+
calculated as the number of correct predictions divided by the total number of predictions. In the
|
61
|
+
context of the `multi_head_fitness` function, the accuracy parameter represents the accuracy
|
62
|
+
of the model's predictions.
|
63
|
+
@param alpha Alpha is a parameter that controls the impact of accuracy on the overall fitness score
|
64
|
+
in the multi_head_fitness function. It is used as an exponent to raise the accuracy value
|
65
|
+
to, influencing its contribution to the fitness calculation.
|
66
|
+
@param beta The `beta` parameter in the `multi_head_fitness` function is used as an exponent
|
67
|
+
in the fitness calculation formula. It controls the impact of the margin loss term on the overall
|
68
|
+
fitness value. A higher value of `beta` will amplify the effect of the margin loss term, making it
|
69
|
+
@param lambda_div The `lambda_div` parameter in the `multi_head_fitness` function represents
|
70
|
+
the weight given to the diversity score in calculating the fitness value. It is a hyperparameter
|
71
|
+
that controls the impact of diversity score on the overall fitness calculation. A higher value of
|
72
|
+
`lambda_div` will increase the importance
|
73
|
+
@return The function `multi_head_fitness` returns the fitness value calculated based on the
|
74
|
+
icput parameters `y_true`, `y_pred`, `diversity_score`, `accuracy`, and optional parameters `alpha`,
|
75
|
+
`beta`, and `lambda_div`. The fitness value is computed using a formula that combines accuracy,
|
76
|
+
margin loss, and diversity score with specified weights and coefficients.
|
77
|
+
"""
|
78
|
+
incorrect = y_true != y_pred
|
79
|
+
margin_loss = cp.abs(y_true[incorrect] - y_pred[incorrect]).mean() if cp.any(incorrect) else 0
|
80
|
+
|
81
|
+
margin_loss = cp.nan_to_num(margin_loss, nan=0.0)
|
82
|
+
accuracy = max(accuracy, 1e-10)
|
83
|
+
|
84
|
+
fitness = (accuracy ** alpha) * ((1 - margin_loss) ** beta) * (1 + lambda_div * diversity_score)
|
85
|
+
return fitness
|