pyerualjetwork 5.1__tar.gz → 5.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-5.1 → pyerualjetwork-5.5}/PKG-INFO +16 -18
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/README.md +15 -17
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/pyerualjetwork/__init__.py +15 -14
- pyerualjetwork-5.5/pyerualjetwork/cpu/__init__.py +24 -0
- pyerualjetwork-5.1/pyerualjetwork/activation_functions_cpu.py → pyerualjetwork-5.5/pyerualjetwork/cpu/activation_functions.py +40 -4
- pyerualjetwork-5.1/pyerualjetwork/data_operations_cpu.py → pyerualjetwork-5.5/pyerualjetwork/cpu/data_ops.py +17 -19
- pyerualjetwork-5.1/pyerualjetwork/metrics_cpu.py → pyerualjetwork-5.5/pyerualjetwork/cpu/metrics.py +3 -1
- pyerualjetwork-5.1/pyerualjetwork/visualizations_cpu.py → pyerualjetwork-5.5/pyerualjetwork/cpu/visualizations.py +96 -139
- pyerualjetwork-5.5/pyerualjetwork/cuda/__init__.py +24 -0
- pyerualjetwork-5.1/pyerualjetwork/activation_functions_cuda.py → pyerualjetwork-5.5/pyerualjetwork/cuda/activation_functions.py +54 -5
- pyerualjetwork-5.1/pyerualjetwork/data_operations_cuda.py → pyerualjetwork-5.5/pyerualjetwork/cuda/data_ops.py +16 -16
- pyerualjetwork-5.1/pyerualjetwork/metrics_cuda.py → pyerualjetwork-5.5/pyerualjetwork/cuda/metrics.py +1 -1
- pyerualjetwork-5.1/pyerualjetwork/visualizations_cuda.py → pyerualjetwork-5.5/pyerualjetwork/cuda/visualizations.py +8 -244
- pyerualjetwork-5.1/pyerualjetwork/ene_cpu.py → pyerualjetwork-5.5/pyerualjetwork/ene.py +29 -95
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/pyerualjetwork/fitness_functions.py +0 -1
- pyerualjetwork-5.5/pyerualjetwork/help.py +17 -0
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/pyerualjetwork/issue_solver.py +39 -11
- pyerualjetwork-5.1/pyerualjetwork/memory_operations.py → pyerualjetwork-5.5/pyerualjetwork/memory_ops.py +1 -1
- pyerualjetwork-5.5/pyerualjetwork/model_ops.py +734 -0
- pyerualjetwork-5.1/pyerualjetwork/neu_cpu.py → pyerualjetwork-5.5/pyerualjetwork/nn.py +199 -91
- pyerualjetwork-5.1/pyerualjetwork/model_operations_cpu.py → pyerualjetwork-5.5/pyerualjetwork/old_cpu_model_ops.py +62 -59
- pyerualjetwork-5.1/pyerualjetwork/model_operations_cuda.py → pyerualjetwork-5.5/pyerualjetwork/old_cuda_model_ops.py +99 -86
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/pyerualjetwork.egg-info/PKG-INFO +16 -18
- pyerualjetwork-5.5/pyerualjetwork.egg-info/SOURCES.txt +30 -0
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/setup.py +1 -1
- pyerualjetwork-5.1/pyerualjetwork/ene_cuda.py +0 -962
- pyerualjetwork-5.1/pyerualjetwork/help.py +0 -17
- pyerualjetwork-5.1/pyerualjetwork/neu_cuda.py +0 -588
- pyerualjetwork-5.1/pyerualjetwork.egg-info/SOURCES.txt +0 -29
- /pyerualjetwork-5.1/pyerualjetwork/loss_functions_cpu.py → /pyerualjetwork-5.5/pyerualjetwork/cpu/loss_functions.py +0 -0
- /pyerualjetwork-5.1/pyerualjetwork/loss_functions_cuda.py → /pyerualjetwork-5.5/pyerualjetwork/cuda/loss_functions.py +0 -0
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/pyerualjetwork/ui.py +0 -0
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/pyerualjetwork.egg-info/dependency_links.txt +0 -0
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/pyerualjetwork.egg-info/top_level.txt +0 -0
- {pyerualjetwork-5.1 → pyerualjetwork-5.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyerualjetwork
|
3
|
-
Version: 5.
|
3
|
+
Version: 5.5
|
4
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
|
@@ -24,17 +24,15 @@ GitHub Page: https://github.com/HCB06/PyerualJetwork
|
|
24
24
|
|
25
25
|
YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7HbsBpCx2VTJ4SK9wcPyse-EHw
|
26
26
|
|
27
|
-
|
27
|
+
installation:
|
28
|
+
'pip install pyerualjetwork'
|
28
29
|
|
29
|
-
|
30
|
-
from pyerualjetwork import
|
31
|
-
from pyerualjetwork
|
32
|
-
from pyerualjetwork
|
33
|
-
|
34
|
-
|
35
|
-
from pyerualjetwork import ene_cuda
|
36
|
-
from pyerualjetwork import data_operations_cuda
|
37
|
-
from pyerualjetwork import model_operations_cuda
|
30
|
+
package modules:
|
31
|
+
'from pyerualjetwork import nn, ene, model_ops, memory_ops'
|
32
|
+
'from pyerualjetwork.cpu data_ops'
|
33
|
+
'from pyerualjetwork.cuda data_ops'
|
34
|
+
|
35
|
+
please read docstrings.
|
38
36
|
|
39
37
|
PyerualJetwork has Issue Solver. This operation provides users ready-to-use functions to identify potential issues
|
40
38
|
caused by version incompatibilities in major updates, ensuring users are not affected by such problems.
|
@@ -74,10 +72,10 @@ PyerualJetwork is free to use for commercial business and individual users.
|
|
74
72
|
PyerualJetwork ready for both eager execution(like PyTorch) and static graph(like Tensorflow) concepts because PyerualJetwork using only functions.
|
75
73
|
For example:
|
76
74
|
|
77
|
-
|
75
|
+
plan_fit function only fits given training data(suitable for dynamic graph) but learn function learns and optimize entire architecture(suitable for static graph). Or more deeper eager executions PyerualJetwork have: cross_over function, mutation 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.
|
78
76
|
<br><br>
|
79
77
|
|
80
|
-
PyerualJetworket includes PLAN, MLP & ENE.<br>
|
78
|
+
PyerualJetworket includes PLAN, MLP, PTNN & ENE.<br>
|
81
79
|
|
82
80
|
PLAN VISION:<br>
|
83
81
|
|
@@ -97,13 +95,13 @@ You can create artificial intelligence models that perform natural language proc
|
|
97
95
|
|
98
96
|

|
99
97
|
|
100
|
-
|
98
|
+
ENE:<br>
|
101
99
|
|
102
100
|
You can create artificial intelligence models that perform reinforcement learning tasks and genetic optimization tasks using the ene module:
|
103
101
|
|
104
|
-
<br>
|
103
|
+
<br>
|
104
|
+
<br><br>
|
107
105
|
|
108
106
|
YOU CAN CREATE DYNAMIC ANIMATIONS OF YOUR MODELS
|
109
107
|
|
@@ -122,6 +120,6 @@ HOW DO I IMPORT IT TO MY PROJECT?
|
|
122
120
|
|
123
121
|
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".
|
124
122
|
|
125
|
-
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork import
|
123
|
+
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork.cpu import nn. Now, you can call the necessary functions from the nn module.
|
126
124
|
|
127
125
|
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.
|
@@ -15,17 +15,15 @@ GitHub Page: https://github.com/HCB06/PyerualJetwork
|
|
15
15
|
|
16
16
|
YouTube Tutorials: https://www.youtube.com/watch?v=6wMQstZ00is&list=PLNgNWpM7HbsBpCx2VTJ4SK9wcPyse-EHw
|
17
17
|
|
18
|
-
|
18
|
+
installation:
|
19
|
+
'pip install pyerualjetwork'
|
19
20
|
|
20
|
-
|
21
|
-
from pyerualjetwork import
|
22
|
-
from pyerualjetwork
|
23
|
-
from pyerualjetwork
|
24
|
-
|
25
|
-
|
26
|
-
from pyerualjetwork import ene_cuda
|
27
|
-
from pyerualjetwork import data_operations_cuda
|
28
|
-
from pyerualjetwork import model_operations_cuda
|
21
|
+
package modules:
|
22
|
+
'from pyerualjetwork import nn, ene, model_ops, memory_ops'
|
23
|
+
'from pyerualjetwork.cpu data_ops'
|
24
|
+
'from pyerualjetwork.cuda data_ops'
|
25
|
+
|
26
|
+
please read docstrings.
|
29
27
|
|
30
28
|
PyerualJetwork has Issue Solver. This operation provides users ready-to-use functions to identify potential issues
|
31
29
|
caused by version incompatibilities in major updates, ensuring users are not affected by such problems.
|
@@ -65,10 +63,10 @@ PyerualJetwork is free to use for commercial business and individual users.
|
|
65
63
|
PyerualJetwork ready for both eager execution(like PyTorch) and static graph(like Tensorflow) concepts because PyerualJetwork using only functions.
|
66
64
|
For example:
|
67
65
|
|
68
|
-
|
66
|
+
plan_fit function only fits given training data(suitable for dynamic graph) but learn function learns and optimize entire architecture(suitable for static graph). Or more deeper eager executions PyerualJetwork have: cross_over function, mutation 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
67
|
<br><br>
|
70
68
|
|
71
|
-
PyerualJetworket includes PLAN, MLP & ENE.<br>
|
69
|
+
PyerualJetworket includes PLAN, MLP, PTNN & ENE.<br>
|
72
70
|
|
73
71
|
PLAN VISION:<br>
|
74
72
|
|
@@ -88,13 +86,13 @@ You can create artificial intelligence models that perform natural language proc
|
|
88
86
|
|
89
87
|

|
90
88
|
|
91
|
-
|
89
|
+
ENE:<br>
|
92
90
|
|
93
91
|
You can create artificial intelligence models that perform reinforcement learning tasks and genetic optimization tasks using the ene module:
|
94
92
|
|
95
|
-
<br>
|
94
|
+
<br>
|
95
|
+
<br><br>
|
98
96
|
|
99
97
|
YOU CAN CREATE DYNAMIC ANIMATIONS OF YOUR MODELS
|
100
98
|
|
@@ -113,6 +111,6 @@ HOW DO I IMPORT IT TO MY PROJECT?
|
|
113
111
|
|
114
112
|
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
113
|
|
116
|
-
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork import
|
114
|
+
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork.cpu import nn. Now, you can call the necessary functions from the nn module.
|
117
115
|
|
118
116
|
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.
|
@@ -9,23 +9,23 @@ The library includes functions for data pre-processing, visualizations, model sa
|
|
9
9
|
training, and both detailed and simplified memory management.
|
10
10
|
|
11
11
|
|
12
|
-
|
12
|
+
PyerualJetwork Main Modules:
|
13
|
+
----------------------------
|
14
|
+
- nn
|
15
|
+
- ene
|
16
|
+
- model_ops
|
17
|
+
|
18
|
+
CPU Main Modules:
|
13
19
|
---------------------------
|
14
|
-
-
|
15
|
-
- ene_cpu
|
16
|
-
- data_operations_cpu
|
17
|
-
- model_operations_cpu
|
20
|
+
- cpu.data_ops
|
18
21
|
|
19
|
-
|
22
|
+
GPU Main Modules:
|
20
23
|
---------------------------
|
21
|
-
-
|
22
|
-
- ene_cuda
|
23
|
-
- data_operations_cuda
|
24
|
-
- model_operations_cuda
|
24
|
+
- cuda.data_ops
|
25
25
|
|
26
26
|
Memory Module:
|
27
27
|
--------------
|
28
|
-
-
|
28
|
+
- memory_ops
|
29
29
|
|
30
30
|
Issue Solver Module:
|
31
31
|
--------------
|
@@ -35,14 +35,14 @@ Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJe
|
|
35
35
|
|
36
36
|
PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
|
37
37
|
|
38
|
-
-
|
38
|
+
- Creator: Hasan Can Beydili
|
39
39
|
- YouTube: https://www.youtube.com/@HasanCanBeydili
|
40
40
|
- Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
|
41
41
|
- Instagram: https://www.instagram.com/canbeydilj
|
42
42
|
- Contact: tchasancan@gmail.com
|
43
43
|
"""
|
44
44
|
|
45
|
-
__version__ = "5.
|
45
|
+
__version__ = "5.5"
|
46
46
|
__update__ = """* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES
|
47
47
|
* PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main
|
48
48
|
* PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
|
@@ -57,7 +57,7 @@ def print_update_notes(update):
|
|
57
57
|
print_version(__version__)
|
58
58
|
print_update_notes(__update__)
|
59
59
|
|
60
|
-
required_modules = ["scipy", "tqdm", "pandas", "numpy", "colorama", "cupy", "psutil"]
|
60
|
+
required_modules = ["scipy", "tqdm", "pandas", "networkx", "seaborn", "numpy", "matplotlib", "colorama", "cupy", "psutil"]
|
61
61
|
|
62
62
|
missing_modules = []
|
63
63
|
for module in required_modules:
|
@@ -71,6 +71,7 @@ if missing_modules:
|
|
71
71
|
f"Missing modules detected: {', '.join(missing_modules)}\n"
|
72
72
|
"Please run the following command to install the missing packages:\n\n"
|
73
73
|
f" pip install {' '.join(missing_modules)}\n\n"
|
74
|
+
"NOTE: needed numpy version --> numpy==1.26.4 and if you have cuda toolkit version 12 you need to install with pip --> pip install cupy-cuda12x. If you have not cuda gpu or toolkit and you want a CPU training doesnt matter. You need to install random cupy version. This is NECESSARY module."
|
74
75
|
"For more information, visit the PyerualJetwork GitHub README.md file:\n"
|
75
76
|
"https://github.com/HCB06/PyerualJetwork/blob/main/README.md"
|
76
77
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"""
|
2
|
+
CPU
|
3
|
+
===
|
4
|
+
The modules contained in this folder and their functions compute data on the central processing unit and store it in the CPU's RAM..
|
5
|
+
|
6
|
+
Modules in the folder:
|
7
|
+
----------------------
|
8
|
+
- activation_functions
|
9
|
+
- data_ops
|
10
|
+
- loss_functions
|
11
|
+
- metrics
|
12
|
+
- visualizations
|
13
|
+
|
14
|
+
Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
|
15
|
+
|
16
|
+
PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
|
17
|
+
|
18
|
+
- Creator: Hasan Can Beydili
|
19
|
+
- YouTube: https://www.youtube.com/@HasanCanBeydili
|
20
|
+
- Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
|
21
|
+
- Instagram: https://www.instagram.com/canbeydilj
|
22
|
+
- Contact: tchasancan@gmail.com
|
23
|
+
|
24
|
+
"""
|
@@ -1,14 +1,51 @@
|
|
1
|
+
"""
|
2
|
+
|
3
|
+
Activation Functions on CPU
|
4
|
+
===========================
|
5
|
+
This module contains activation functions that run on the CPU.
|
6
|
+
|
7
|
+
|
8
|
+
Module functions:
|
9
|
+
-----------------
|
10
|
+
- 'sigmoid': Sigmoid,
|
11
|
+
- 'mod_circular': modular_circular_activation,
|
12
|
+
- 'tanh_circular': tanh_circular_activation,
|
13
|
+
- 'leaky_relu': leaky_relu,
|
14
|
+
- 'relu': Relu,
|
15
|
+
- 'gelu': gelu,
|
16
|
+
- 'tanh': tanh,
|
17
|
+
- 'sinakt': sinakt,
|
18
|
+
- 'p_squared': p_squared,
|
19
|
+
- 'sglu': lambda x: sglu(x, alpha=1.0),
|
20
|
+
- 'dlrelu': dlrelu,
|
21
|
+
- 'sin_plus': sin_plus,
|
22
|
+
- 'acos': lambda x: acos(x, alpha=1.0, beta=0.0),
|
23
|
+
- 'isra': isra,
|
24
|
+
- 'waveakt': waveakt,
|
25
|
+
- 'arctan': arctan,
|
26
|
+
- 'bent_identity': bent_identity,
|
27
|
+
- 'softsign': softsign,
|
28
|
+
- 'pwl': pwl,
|
29
|
+
- 'sine': sine,
|
30
|
+
- 'tanh_square': tanh_square,
|
31
|
+
- 'linear':,
|
32
|
+
- 'sine_square': sine_square,
|
33
|
+
- 'logarithmic': logarithmic,
|
34
|
+
- 'sine_offset': lambda x: sine_offset(x, 1.0),
|
35
|
+
- 'spiral': spiral_activation,
|
36
|
+
- 'circular': circular_activation
|
37
|
+
- Softmax()
|
38
|
+
"""
|
39
|
+
|
1
40
|
import numpy as np
|
2
41
|
from scipy.special import expit, softmax
|
3
42
|
import warnings
|
4
43
|
|
5
|
-
|
6
44
|
# ACTIVATION FUNCTIONS -----
|
7
45
|
|
8
46
|
def all_activations():
|
9
|
-
|
47
|
+
|
10
48
|
activations_list = ['linear', 'sigmoid', 'relu', 'tanh', 'circular', 'spiral', 'sin_plus', 'mod_circular', 'tanh_circular', 'leaky_relu', 'gelu', 'sinakt', 'p_squared', 'sglu', 'dlrelu', 'acos', 'isra', 'waveakt', 'arctan', 'bent_identity', 'softsign', 'pwl', 'sine', 'tanh_square', 'sine_square', 'logarithmic', 'sine_offset']
|
11
|
-
# suggest: tanh, arctan, selu, elu, dlrelu, isra, bent_identity
|
12
49
|
return activations_list
|
13
50
|
|
14
51
|
def spiral_activation(x):
|
@@ -72,7 +109,6 @@ def Relu(
|
|
72
109
|
|
73
110
|
return np.maximum(0, x)
|
74
111
|
|
75
|
-
|
76
112
|
def tanh(x):
|
77
113
|
return np.tanh(x)
|
78
114
|
|
@@ -21,7 +21,7 @@ Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJe
|
|
21
21
|
|
22
22
|
PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
|
23
23
|
|
24
|
-
-
|
24
|
+
- Creator: Hasan Can Beydili
|
25
25
|
- YouTube: https://www.youtube.com/@HasanCanBeydili
|
26
26
|
- Linkedin: https://www.linkedin.com/in/hasan-can-beydili-77a1b9270/
|
27
27
|
- Instagram: https://www.instagram.com/canbeydilj
|
@@ -31,7 +31,6 @@ PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welco
|
|
31
31
|
from tqdm import tqdm
|
32
32
|
import numpy as np
|
33
33
|
from colorama import Fore, Style
|
34
|
-
import sys
|
35
34
|
import math
|
36
35
|
|
37
36
|
def encode_one_hot(y_train, y_test=None, summary=False):
|
@@ -46,7 +45,7 @@ def encode_one_hot(y_train, y_test=None, summary=False):
|
|
46
45
|
Returns:
|
47
46
|
tuple: One-hot encoded y_train and (if given) y_test.
|
48
47
|
"""
|
49
|
-
from
|
48
|
+
from ..memory_ops import optimize_labels
|
50
49
|
|
51
50
|
classes = np.unique(y_train)
|
52
51
|
class_count = len(classes)
|
@@ -154,8 +153,8 @@ def manuel_balancer(x_train, y_train, target_samples_per_class, dtype=np.float32
|
|
154
153
|
x_balanced -- Balanced input dataset (numpy array format)
|
155
154
|
y_balanced -- Balanced class labels (one-hot encoded, numpy array format)
|
156
155
|
"""
|
157
|
-
from
|
158
|
-
from
|
156
|
+
from ..ui import loading_bars, get_loading_bar_style
|
157
|
+
from ..memory_ops import transfer_to_cpu
|
159
158
|
|
160
159
|
x_train = transfer_to_cpu(x_train, dtype=dtype)
|
161
160
|
|
@@ -229,8 +228,8 @@ def auto_balancer(x_train, y_train, dtype=np.float32):
|
|
229
228
|
Returns:
|
230
229
|
tuple: A tuple containing balanced input data and labels.
|
231
230
|
"""
|
232
|
-
from
|
233
|
-
from
|
231
|
+
from ..ui import loading_bars, get_loading_bar_style
|
232
|
+
from ..memory_ops import transfer_to_cpu
|
234
233
|
|
235
234
|
x_train = transfer_to_cpu(x_train, dtype=dtype)
|
236
235
|
|
@@ -268,9 +267,8 @@ def auto_balancer(x_train, y_train, dtype=np.float32):
|
|
268
267
|
|
269
268
|
print(Fore.GREEN + "Data Succesfully Balanced from: " + str(len(x_train)
|
270
269
|
) + " to: " + str(len(BalancedInputs)) + ". from: auto_balancer " + Style.RESET_ALL)
|
271
|
-
except:
|
272
|
-
|
273
|
-
sys.exit()
|
270
|
+
except Exception as e:
|
271
|
+
raise RuntimeError(Fore.RED + f"ERROR: An error occurred {e}" + Style.RESET_ALL) from e
|
274
272
|
|
275
273
|
BalancedInputs = BalancedInputs.astype(dtype, copy=False)
|
276
274
|
BalancedLabels = BalancedLabels.astype(dtype=y_train.dtype, copy=False)
|
@@ -284,9 +282,9 @@ def synthetic_augmentation(x, y, dtype=np.float32):
|
|
284
282
|
"""
|
285
283
|
Generates synthetic examples to balance classes with fewer examples using numpy.
|
286
284
|
Args:
|
287
|
-
|
285
|
+
x: numpy array format
|
288
286
|
|
289
|
-
|
287
|
+
y: numpy array format (one-hot encoded)
|
290
288
|
|
291
289
|
dtype (numpy.dtype): Data type for the arrays. cp.float32 by default. Example: cp.float64 or cp.float16.
|
292
290
|
|
@@ -295,8 +293,8 @@ def synthetic_augmentation(x, y, dtype=np.float32):
|
|
295
293
|
Returns:
|
296
294
|
x_train_balanced, y_train_balanced (numpy array format)
|
297
295
|
"""
|
298
|
-
from
|
299
|
-
from
|
296
|
+
from ..ui import loading_bars, get_loading_bar_style
|
297
|
+
from ..memory_ops import transfer_to_cpu
|
300
298
|
|
301
299
|
x = transfer_to_cpu(x, dtype=dtype)
|
302
300
|
|
@@ -438,12 +436,12 @@ def find_closest_factors(a):
|
|
438
436
|
return i, j
|
439
437
|
|
440
438
|
|
441
|
-
def batcher(
|
439
|
+
def batcher(x, y, batch_size=1):
|
442
440
|
|
443
441
|
if batch_size == 1:
|
444
|
-
return
|
442
|
+
return x, y
|
445
443
|
|
446
|
-
y_labels = np.argmax(
|
444
|
+
y_labels = np.argmax(y, axis=1)
|
447
445
|
|
448
446
|
sampled_x, sampled_y = [], []
|
449
447
|
|
@@ -455,7 +453,7 @@ def batcher(x_test, y_test, batch_size=1):
|
|
455
453
|
|
456
454
|
sampled_indices = np.random.choice(class_indices, num_samples, replace=False)
|
457
455
|
|
458
|
-
sampled_x.append(
|
459
|
-
sampled_y.append(
|
456
|
+
sampled_x.append(x[sampled_indices])
|
457
|
+
sampled_y.append(y[sampled_indices])
|
460
458
|
|
461
459
|
return np.concatenate(sampled_x), np.concatenate(sampled_y)
|
pyerualjetwork-5.1/pyerualjetwork/metrics_cpu.py → pyerualjetwork-5.5/pyerualjetwork/cpu/metrics.py
RENAMED
@@ -13,12 +13,13 @@ def metrics(y_ts, test_preds, average='weighted'):
|
|
13
13
|
tuple: Precision, recall, F1 score.
|
14
14
|
"""
|
15
15
|
|
16
|
-
from .
|
16
|
+
from .data_ops import decode_one_hot
|
17
17
|
|
18
18
|
y_test_d = decode_one_hot(y_ts)
|
19
19
|
y_test_d = np.array(y_test_d)
|
20
20
|
y_pred = np.array(test_preds)
|
21
21
|
|
22
|
+
|
22
23
|
if y_test_d.ndim > 1:
|
23
24
|
y_test_d = y_test_d.reshape(-1)
|
24
25
|
if y_pred.ndim > 1:
|
@@ -158,6 +159,7 @@ def confusion_matrix(y_true, y_pred, class_count):
|
|
158
159
|
for i in range(len(y_true)):
|
159
160
|
true_label = y_true[i]
|
160
161
|
pred_label = y_pred[i]
|
162
|
+
|
161
163
|
confusion[true_label, pred_label] += 1
|
162
164
|
|
163
165
|
return confusion
|