pyerualjetwork 4.8b0__tar.gz → 5__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.8b0 → pyerualjetwork-5}/PKG-INFO +19 -16
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/README.md +17 -14
- pyerualjetwork-5/pyerualjetwork/__init__.py +73 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/data_operations.py +31 -1
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/data_operations_cuda.py +30 -0
- pyerualjetwork-4.8b0/pyerualjetwork/planeat.py → pyerualjetwork-5/pyerualjetwork/ene.py +51 -33
- pyerualjetwork-4.8b0/pyerualjetwork/planeat_cuda.py → pyerualjetwork-5/pyerualjetwork/ene_cuda.py +47 -30
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/help.py +2 -2
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/memory_operations.py +26 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/model_operations.py +83 -38
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/model_operations_cuda.py +79 -33
- pyerualjetwork-4.8b0/pyerualjetwork/plan.py → pyerualjetwork-5/pyerualjetwork/neu.py +68 -53
- pyerualjetwork-4.8b0/pyerualjetwork/plan_cuda.py → pyerualjetwork-5/pyerualjetwork/neu_cuda.py +75 -60
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/visualizations.py +10 -10
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/visualizations_cuda.py +10 -10
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork.egg-info/PKG-INFO +19 -16
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork.egg-info/SOURCES.txt +4 -4
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/setup.py +2 -2
- pyerualjetwork-4.8b0/pyerualjetwork/__init__.py +0 -33
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/activation_functions.py +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/activation_functions_cuda.py +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/fitness_functions.py +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/loss_functions.py +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/loss_functions_cuda.py +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/metrics.py +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/metrics_cuda.py +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork/ui.py +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork.egg-info/dependency_links.txt +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/pyerualjetwork.egg-info/top_level.txt +0 -0
- {pyerualjetwork-4.8b0 → pyerualjetwork-5}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyerualjetwork
|
3
|
-
Version:
|
4
|
-
Summary:
|
3
|
+
Version: 5
|
4
|
+
Summary: PyereualJetwork is a GPU-accelerated machine learning library in Python for professionals and researchers. It features PLAN, MLP, Deep Learning training, and ENE (Eugenic NeuroEvolution) for genetic optimization, applicable to genetic algorithms or Reinforcement Learning (RL). The library includes data pre-processing, visualizations, model saving/loading, prediction, evaluation, training, and detailed or simplified memory management.
|
5
5
|
Author: Hasan Can Beydili
|
6
6
|
Author-email: tchasancan@gmail.com
|
7
7
|
Keywords: model evaluation,classification,potentiation learning artificial neural networks,NEAT,genetic algorithms,reinforcement learning,neural networks
|
@@ -26,13 +26,13 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
26
26
|
|
27
27
|
pip install pyerualjetwork
|
28
28
|
|
29
|
-
from pyerualjetwork import
|
30
|
-
from pyerualjetwork import
|
29
|
+
from pyerualjetwork import neu
|
30
|
+
from pyerualjetwork import ene
|
31
31
|
from pyerualjetwork import data_operations
|
32
32
|
from pyerualjetwork import model_operations
|
33
33
|
|
34
|
-
from pyerualjetwork import
|
35
|
-
from pyerualjetwork import
|
34
|
+
from pyerualjetwork import neu_cuda
|
35
|
+
from pyerualjetwork import ene_cuda
|
36
36
|
from pyerualjetwork import data_operations_cuda
|
37
37
|
from pyerualjetwork import model_operations_cuda
|
38
38
|
|
@@ -43,7 +43,7 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
43
43
|
'tqdm==4.66.4',
|
44
44
|
'pandas==2.2.2',
|
45
45
|
'networkx==3.3',
|
46
|
-
|
46
|
+
'seaborn==0.13.2',
|
47
47
|
'numpy==1.26.4',
|
48
48
|
'matplotlib==3.9.0',
|
49
49
|
'colorama==0.4.6',
|
@@ -57,10 +57,13 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
57
57
|
|
58
58
|
ABOUT PYERUALJETWORK:
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
PyereualJetwork is a large, GPU-accelerated machine learning library in Python designed for professionals and researchers.
|
61
|
+
It features PLAN, MLP, and Deep Learning training, as well as ENE (Eugenic NeuroEvolution) for genetic optimization,
|
62
|
+
which can also be applied to genetic algorithms or Reinforcement Learning (RL) problems.
|
63
|
+
The library includes functions for data pre-processing, visualizations, model saving and loading, prediction and evaluation,
|
64
|
+
training, and both detailed and simplified memory management. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4862342. (THIS ARTICLE IS FIRST VERSION OF PLAN.) MODERN VERSION OF PLAN: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PLAN/PLAN.pdf
|
65
|
+
Both the PLAN algorithm ENE algorithm and the PyerualJetwork library were created by Author, and all rights are reserved by Author.
|
62
66
|
PyerualJetwork is free to use for commercial business and individual users.
|
63
|
-
As of 12/21/2024, the library includes PLAN and PLANEAT module, but other machine learning modules are expected to be added in the future.
|
64
67
|
|
65
68
|
PyerualJetwork ready for both eager execution(like PyTorch) and static graph(like Tensorflow) concepts because PyerualJetwork using only functions.
|
66
69
|
For example:
|
@@ -68,13 +71,13 @@ For example:
|
|
68
71
|
fit function only fits given training data(suitable for dynamic graph) but learner function learns and optimize entire architecture(suitable for static graph). Or more deeper eager executions PyerualJetwork have: feed_forward function, list of activation functions, loss functions. You can create your unique model architecture. Move your data to GPU or CPU or manage how much should in GPU, Its all up to you.
|
69
72
|
<br><br>
|
70
73
|
|
71
|
-
PyerualJetworket includes
|
74
|
+
PyerualJetworket includes PLAN, MLP & ENE.<br>
|
72
75
|
|
73
76
|
PLAN VISION:<br>
|
74
77
|
|
75
78
|

|
76
79
|
|
77
|
-
You can create artificial intelligence models that perform computer vision tasks using the
|
80
|
+
You can create artificial intelligence models that perform computer vision tasks using the neu module:<br>
|
78
81
|
|
79
82
|
<br><br><br>
|
80
83
|
<br><br><br>
|
@@ -84,13 +87,13 @@ NLPlan:<br>
|
|
84
87
|
|
85
88
|
<br>
|
86
89
|
|
87
|
-
You can create artificial intelligence models that perform natural language processing tasks using the
|
90
|
+
You can create artificial intelligence models that perform natural language processing tasks using the neu module:
|
88
91
|
|
89
92
|

|
90
93
|
|
91
94
|
PLANEAT:<br>
|
92
95
|
|
93
|
-
You can create artificial intelligence models that perform reinforcement learning tasks and genetic optimization tasks using the
|
96
|
+
You can create artificial intelligence models that perform reinforcement learning tasks and genetic optimization tasks using the ene module:
|
94
97
|
|
95
98
|
<br>
|
96
99
|
<br>
|
@@ -113,6 +116,6 @@ HOW DO I IMPORT IT TO MY PROJECT?
|
|
113
116
|
|
114
117
|
Anaconda users can access the 'Anaconda Prompt' terminal from the Start menu and add the necessary library modules to the Python module search queue by typing "pip install pyerualjetwork" and pressing enter. If you are not using Anaconda, you can simply open the 'cmd' Windows command terminal from the Start menu and type "pip install PyerualJetwork". (Visual Studio Code reccomended) After installation, it's important to periodically open the terminal of the environment you are using and stay up to date by using the command "pip install PyerualJetwork --upgrade".
|
115
118
|
|
116
|
-
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork import
|
119
|
+
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork import neu”. Now, you can call the necessary functions from the neu module.
|
117
120
|
|
118
|
-
The PLAN algorithm will not be explained in this document. This document focuses on how professionals can integrate and use PyerualJetwork in their systems. However, briefly, the PLAN algorithm can be described as a classification algorithm. PLAN algorithm achieves this task with an incredibly energy-efficient, fast, and hyperparameter-free user-friendly approach. For more detailed information, you can check out .pdf) file.
|
121
|
+
The PLAN algorithm & ENE algorithm will not be explained in this document. This document focuses on how professionals can integrate and use PyerualJetwork in their systems. However, briefly, the PLAN algorithm can be described as a classification algorithm. PLAN algorithm achieves this task with an incredibly energy-efficient, fast, and hyperparameter-free user-friendly approach. For more detailed information, you can check out .pdf) file.
|
@@ -17,13 +17,13 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
17
17
|
|
18
18
|
pip install pyerualjetwork
|
19
19
|
|
20
|
-
from pyerualjetwork import
|
21
|
-
from pyerualjetwork import
|
20
|
+
from pyerualjetwork import neu
|
21
|
+
from pyerualjetwork import ene
|
22
22
|
from pyerualjetwork import data_operations
|
23
23
|
from pyerualjetwork import model_operations
|
24
24
|
|
25
|
-
from pyerualjetwork import
|
26
|
-
from pyerualjetwork import
|
25
|
+
from pyerualjetwork import neu_cuda
|
26
|
+
from pyerualjetwork import ene_cuda
|
27
27
|
from pyerualjetwork import data_operations_cuda
|
28
28
|
from pyerualjetwork import model_operations_cuda
|
29
29
|
|
@@ -34,7 +34,7 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
34
34
|
'tqdm==4.66.4',
|
35
35
|
'pandas==2.2.2',
|
36
36
|
'networkx==3.3',
|
37
|
-
|
37
|
+
'seaborn==0.13.2',
|
38
38
|
'numpy==1.26.4',
|
39
39
|
'matplotlib==3.9.0',
|
40
40
|
'colorama==0.4.6',
|
@@ -48,10 +48,13 @@ YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7Hbs
|
|
48
48
|
|
49
49
|
ABOUT PYERUALJETWORK:
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
PyereualJetwork is a large, GPU-accelerated machine learning library in Python designed for professionals and researchers.
|
52
|
+
It features PLAN, MLP, and Deep Learning training, as well as ENE (Eugenic NeuroEvolution) for genetic optimization,
|
53
|
+
which can also be applied to genetic algorithms or Reinforcement Learning (RL) problems.
|
54
|
+
The library includes functions for data pre-processing, visualizations, model saving and loading, prediction and evaluation,
|
55
|
+
training, and both detailed and simplified memory management. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4862342. (THIS ARTICLE IS FIRST VERSION OF PLAN.) MODERN VERSION OF PLAN: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PLAN/PLAN.pdf
|
56
|
+
Both the PLAN algorithm ENE algorithm and the PyerualJetwork library were created by Author, and all rights are reserved by Author.
|
53
57
|
PyerualJetwork is free to use for commercial business and individual users.
|
54
|
-
As of 12/21/2024, the library includes PLAN and PLANEAT module, but other machine learning modules are expected to be added in the future.
|
55
58
|
|
56
59
|
PyerualJetwork ready for both eager execution(like PyTorch) and static graph(like Tensorflow) concepts because PyerualJetwork using only functions.
|
57
60
|
For example:
|
@@ -59,13 +62,13 @@ For example:
|
|
59
62
|
fit function only fits given training data(suitable for dynamic graph) but learner function learns and optimize entire architecture(suitable for static graph). Or more deeper eager executions PyerualJetwork have: feed_forward function, list of activation functions, loss functions. You can create your unique model architecture. Move your data to GPU or CPU or manage how much should in GPU, Its all up to you.
|
60
63
|
<br><br>
|
61
64
|
|
62
|
-
PyerualJetworket includes
|
65
|
+
PyerualJetworket includes PLAN, MLP & ENE.<br>
|
63
66
|
|
64
67
|
PLAN VISION:<br>
|
65
68
|
|
66
69
|

|
67
70
|
|
68
|
-
You can create artificial intelligence models that perform computer vision tasks using the
|
71
|
+
You can create artificial intelligence models that perform computer vision tasks using the neu module:<br>
|
69
72
|
|
70
73
|
<br><br><br>
|
71
74
|
<br><br><br>
|
@@ -75,13 +78,13 @@ NLPlan:<br>
|
|
75
78
|
|
76
79
|
<br>
|
77
80
|
|
78
|
-
You can create artificial intelligence models that perform natural language processing tasks using the
|
81
|
+
You can create artificial intelligence models that perform natural language processing tasks using the neu module:
|
79
82
|
|
80
83
|

|
81
84
|
|
82
85
|
PLANEAT:<br>
|
83
86
|
|
84
|
-
You can create artificial intelligence models that perform reinforcement learning tasks and genetic optimization tasks using the
|
87
|
+
You can create artificial intelligence models that perform reinforcement learning tasks and genetic optimization tasks using the ene module:
|
85
88
|
|
86
89
|
<br>
|
87
90
|
<br>
|
@@ -104,6 +107,6 @@ HOW DO I IMPORT IT TO MY PROJECT?
|
|
104
107
|
|
105
108
|
Anaconda users can access the 'Anaconda Prompt' terminal from the Start menu and add the necessary library modules to the Python module search queue by typing "pip install pyerualjetwork" and pressing enter. If you are not using Anaconda, you can simply open the 'cmd' Windows command terminal from the Start menu and type "pip install PyerualJetwork". (Visual Studio Code reccomended) After installation, it's important to periodically open the terminal of the environment you are using and stay up to date by using the command "pip install PyerualJetwork --upgrade".
|
106
109
|
|
107
|
-
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork import
|
110
|
+
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork import neu”. Now, you can call the necessary functions from the neu module.
|
108
111
|
|
109
|
-
The PLAN algorithm will not be explained in this document. This document focuses on how professionals can integrate and use PyerualJetwork in their systems. However, briefly, the PLAN algorithm can be described as a classification algorithm. PLAN algorithm achieves this task with an incredibly energy-efficient, fast, and hyperparameter-free user-friendly approach. For more detailed information, you can check out .pdf) file.
|
112
|
+
The PLAN algorithm & ENE algorithm will not be explained in this document. This document focuses on how professionals can integrate and use PyerualJetwork in their systems. However, briefly, the PLAN algorithm can be described as a classification algorithm. PLAN algorithm achieves this task with an incredibly energy-efficient, fast, and hyperparameter-free user-friendly approach. For more detailed information, you can check out .pdf) file.
|
@@ -0,0 +1,73 @@
|
|
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"
|
42
|
+
__update__ = """* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES
|
43
|
+
* PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main
|
44
|
+
* PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
|
45
|
+
* YouTube tutorials: https://www.youtube.com/@HasanCanBeydili"""
|
46
|
+
|
47
|
+
def print_version(version):
|
48
|
+
print(f"PyerualJetwork Version {version}\n")
|
49
|
+
|
50
|
+
def print_update_notes(update):
|
51
|
+
print(f"Notes:\n{update}")
|
52
|
+
|
53
|
+
print_version(__version__)
|
54
|
+
print_update_notes(__update__)
|
55
|
+
|
56
|
+
required_modules = ["scipy", "tqdm", "pandas", "numpy", "colorama", "cupy", "psutil"]
|
57
|
+
|
58
|
+
missing_modules = []
|
59
|
+
for module in required_modules:
|
60
|
+
try:
|
61
|
+
__import__(module)
|
62
|
+
except ModuleNotFoundError:
|
63
|
+
missing_modules.append(module)
|
64
|
+
|
65
|
+
if missing_modules:
|
66
|
+
raise ImportError(
|
67
|
+
f"Missing modules detected: {', '.join(missing_modules)}\n"
|
68
|
+
"Please run the following command to install the missing packages:\n\n"
|
69
|
+
f" pip install {' '.join(missing_modules)}\n\n"
|
70
|
+
"For more information, visit the PyerualJetwork GitHub README.md file:\n"
|
71
|
+
"https://github.com/HCB06/PyerualJetwork/blob/main/README.md"
|
72
|
+
|
73
|
+
)
|
@@ -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
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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,
|
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
|
-
|
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
|
-
|
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):
|
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
|
-
|
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
|
-
|
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
|
-
-
|
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,
|
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
|
-
|
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(
|
339
|
-
bad_activations = list(
|
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
|
-
|
489
|
+
activations = child_act + mutated_act
|
473
490
|
|
474
491
|
if save_best_genome:
|
475
492
|
weights[0] = best_weight
|
476
|
-
|
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)
|
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,
|
532
|
+
return weights, activations
|
515
533
|
|
516
534
|
|
517
|
-
def evaluate(Input, weights,
|
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
|
-
|
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,
|
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(
|
547
|
-
|
548
|
-
elif isinstance(
|
549
|
-
|
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,
|
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,
|
581
|
+
Input = apply_activation(Input, activations)
|
564
582
|
result = Input @ weights.T
|
565
583
|
|
566
584
|
return result
|