pyerualjetwork 5.2__py3-none-any.whl → 5.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.
- pyerualjetwork/__init__.py +15 -14
- pyerualjetwork/cpu/__init__.py +24 -0
- pyerualjetwork/{activation_functions_cpu.py → cpu/activation_functions.py} +40 -4
- pyerualjetwork/{data_operations_cpu.py → cpu/data_ops.py} +17 -19
- pyerualjetwork/{metrics_cpu.py → cpu/metrics.py} +3 -1
- pyerualjetwork/{visualizations_cpu.py → cpu/visualizations.py} +96 -139
- pyerualjetwork/cuda/__init__.py +24 -0
- pyerualjetwork/{activation_functions_cuda.py → cuda/activation_functions.py} +54 -5
- pyerualjetwork/{data_operations_cuda.py → cuda/data_ops.py} +16 -16
- pyerualjetwork/{metrics_cuda.py → cuda/metrics.py} +1 -1
- pyerualjetwork/{visualizations_cuda.py → cuda/visualizations.py} +8 -244
- pyerualjetwork/{ene_cpu.py → ene.py} +29 -95
- pyerualjetwork/help.py +5 -5
- pyerualjetwork/issue_solver.py +39 -11
- pyerualjetwork/{memory_operations.py → memory_ops.py} +1 -1
- pyerualjetwork/model_ops.py +734 -0
- pyerualjetwork/{neu_cpu.py → nn.py} +199 -91
- pyerualjetwork/{model_operations_cpu.py → old_cpu_model_ops.py} +62 -59
- pyerualjetwork/{model_operations_cuda.py → old_cuda_model_ops.py} +99 -86
- {pyerualjetwork-5.2.dist-info → pyerualjetwork-5.5.dist-info}/METADATA +16 -18
- pyerualjetwork-5.5.dist-info/RECORD +27 -0
- pyerualjetwork/ene_cuda.py +0 -962
- pyerualjetwork/neu_cuda.py +0 -588
- pyerualjetwork-5.2.dist-info/RECORD +0 -26
- /pyerualjetwork/{loss_functions_cpu.py → cpu/loss_functions.py} +0 -0
- /pyerualjetwork/{loss_functions_cuda.py → cuda/loss_functions.py} +0 -0
- {pyerualjetwork-5.2.dist-info → pyerualjetwork-5.5.dist-info}/WHEEL +0 -0
- {pyerualjetwork-5.2.dist-info → pyerualjetwork-5.5.dist-info}/top_level.txt +0 -0
pyerualjetwork/__init__.py
CHANGED
@@ -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)
|
@@ -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
|