pyerualjetwork 5.37__py3-none-any.whl → 5.40a1__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 +12 -11
- pyerualjetwork/cpu/__init__.py +1 -4
- pyerualjetwork/cpu/metrics.py +2 -0
- pyerualjetwork/cpu/visualizations.py +102 -134
- pyerualjetwork/cuda/__init__.py +1 -4
- pyerualjetwork/cuda/activation_functions.py +3 -0
- pyerualjetwork/cuda/data_ops.py +1 -1
- pyerualjetwork/cuda/visualizations.py +4 -240
- pyerualjetwork/{cpu/ene.py → ene.py} +5 -57
- pyerualjetwork/help.py +1 -1
- pyerualjetwork/issue_solver.py +38 -10
- pyerualjetwork/model_ops.py +692 -0
- pyerualjetwork/{cpu/nn.py → nn.py} +210 -85
- pyerualjetwork/{cuda/model_ops.py → old_cuda_model_ops.py} +1 -1
- {pyerualjetwork-5.37.dist-info → pyerualjetwork-5.40a1.dist-info}/METADATA +8 -7
- pyerualjetwork-5.40a1.dist-info/RECORD +27 -0
- pyerualjetwork/cuda/ene.py +0 -948
- pyerualjetwork/cuda/nn.py +0 -605
- pyerualjetwork-5.37.dist-info/RECORD +0 -28
- /pyerualjetwork/{cpu/model_ops.py → old_cpu_model_ops.py} +0 -0
- {pyerualjetwork-5.37.dist-info → pyerualjetwork-5.40a1.dist-info}/WHEEL +0 -0
- {pyerualjetwork-5.37.dist-info → pyerualjetwork-5.40a1.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
|
-
- cpu.nn
|
15
|
-
- cpu.ene
|
16
20
|
- cpu.data_ops
|
17
|
-
- cpu.model_ops
|
18
21
|
|
19
|
-
|
22
|
+
GPU Main Modules:
|
20
23
|
---------------------------
|
21
|
-
- cuda.nn
|
22
|
-
- cuda.ene
|
23
24
|
- cuda.data_ops
|
24
|
-
- cuda.model_ops
|
25
25
|
|
26
26
|
Memory Module:
|
27
27
|
--------------
|
28
|
-
-
|
28
|
+
- memory_ops
|
29
29
|
|
30
30
|
Issue Solver Module:
|
31
31
|
--------------
|
@@ -42,7 +42,7 @@ PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welco
|
|
42
42
|
- Contact: tchasancan@gmail.com
|
43
43
|
"""
|
44
44
|
|
45
|
-
__version__ = "5.
|
45
|
+
__version__ = "5.40a1"
|
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-cuda12x", "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"
|
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
|
|
pyerualjetwork/cpu/__init__.py
CHANGED
@@ -6,12 +6,9 @@ The modules contained in this folder and their functions compute data on the cen
|
|
6
6
|
Modules in the folder:
|
7
7
|
----------------------
|
8
8
|
- activation_functions
|
9
|
-
-
|
10
|
-
- ene
|
9
|
+
- data_ops
|
11
10
|
- loss_functions
|
12
11
|
- metrics
|
13
|
-
- model_operations
|
14
|
-
- nn
|
15
12
|
- visualizations
|
16
13
|
|
17
14
|
Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
|
pyerualjetwork/cpu/metrics.py
CHANGED
@@ -19,6 +19,7 @@ def metrics(y_ts, test_preds, average='weighted'):
|
|
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
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import networkx as nx
|
2
2
|
import matplotlib.pyplot as plt
|
3
3
|
import numpy as np
|
4
|
+
import cupy as cp
|
4
5
|
from scipy.spatial import ConvexHull
|
5
6
|
import seaborn as sns
|
6
7
|
from matplotlib.animation import ArtistAnimation
|
@@ -86,7 +87,7 @@ def draw_model_architecture(model_name, model_path=''):
|
|
86
87
|
Visualizes the architecture of a neural network model with multiple inputs based on activation functions.
|
87
88
|
"""
|
88
89
|
|
89
|
-
from
|
90
|
+
from ..model_ops import load_model, get_scaler, get_act, get_weights
|
90
91
|
|
91
92
|
model = load_model(model_name=model_name, model_path=model_path)
|
92
93
|
|
@@ -187,9 +188,6 @@ def draw_activations(x_train, activation):
|
|
187
188
|
if activation == 'sigmoid':
|
188
189
|
result = af.Sigmoid(x_train)
|
189
190
|
|
190
|
-
elif activation == 'swish':
|
191
|
-
result = af.swish(x_train)
|
192
|
-
|
193
191
|
elif activation == 'circular':
|
194
192
|
result = af.circular_activation(x_train)
|
195
193
|
|
@@ -205,18 +203,9 @@ def draw_activations(x_train, activation):
|
|
205
203
|
elif activation == 'relu':
|
206
204
|
result = af.Relu(x_train)
|
207
205
|
|
208
|
-
elif activation == 'softplus':
|
209
|
-
result = af.softplus(x_train)
|
210
|
-
|
211
|
-
elif activation == 'elu':
|
212
|
-
result = af.elu(x_train)
|
213
|
-
|
214
206
|
elif activation == 'gelu':
|
215
207
|
result = af.gelu(x_train)
|
216
208
|
|
217
|
-
elif activation == 'selu':
|
218
|
-
result = af.selu(x_train)
|
219
|
-
|
220
209
|
elif activation == 'softmax':
|
221
210
|
result = af.Softmax(x_train)
|
222
211
|
|
@@ -235,24 +224,12 @@ def draw_activations(x_train, activation):
|
|
235
224
|
elif activation == 'dlrelu':
|
236
225
|
result = af.dlrelu(x_train)
|
237
226
|
|
238
|
-
elif activation == 'exsig':
|
239
|
-
result = af.exsig(x_train)
|
240
|
-
|
241
227
|
elif activation == 'sin_plus':
|
242
228
|
result = af.sin_plus(x_train)
|
243
229
|
|
244
230
|
elif activation == 'acos':
|
245
231
|
result = af.acos(x_train, alpha=1.0, beta=0.0)
|
246
232
|
|
247
|
-
elif activation == 'gla':
|
248
|
-
result = af.gla(x_train, alpha=1.0, mu=0.0)
|
249
|
-
|
250
|
-
elif activation == 'srelu':
|
251
|
-
result = af.srelu(x_train)
|
252
|
-
|
253
|
-
elif activation == 'qelu':
|
254
|
-
result = af.qelu(x_train)
|
255
|
-
|
256
233
|
elif activation == 'isra':
|
257
234
|
result = af.isra(x_train)
|
258
235
|
|
@@ -265,54 +242,27 @@ def draw_activations(x_train, activation):
|
|
265
242
|
elif activation == 'bent_identity':
|
266
243
|
result = af.bent_identity(x_train)
|
267
244
|
|
268
|
-
elif activation == 'sech':
|
269
|
-
result = af.sech(x_train)
|
270
|
-
|
271
245
|
elif activation == 'softsign':
|
272
246
|
result = af.softsign(x_train)
|
273
247
|
|
274
248
|
elif activation == 'pwl':
|
275
249
|
result = af.pwl(x_train)
|
276
250
|
|
277
|
-
elif activation == 'cubic':
|
278
|
-
result = af.cubic(x_train)
|
279
|
-
|
280
|
-
elif activation == 'gaussian':
|
281
|
-
result = af.gaussian(x_train)
|
282
|
-
|
283
251
|
elif activation == 'sine':
|
284
252
|
result = af.sine(x_train)
|
285
253
|
|
286
254
|
elif activation == 'tanh_square':
|
287
255
|
result = af.tanh_square(x_train)
|
288
256
|
|
289
|
-
elif activation == 'mod_sigmoid':
|
290
|
-
result = af.mod_sigmoid(x_train)
|
291
|
-
|
292
257
|
elif activation == 'linear':
|
293
258
|
result = x_train
|
294
259
|
|
295
|
-
elif activation == 'quartic':
|
296
|
-
result = af.quartic(x_train)
|
297
|
-
|
298
|
-
elif activation == 'square_quartic':
|
299
|
-
result = af.square_quartic(x_train)
|
300
|
-
|
301
|
-
elif activation == 'cubic_quadratic':
|
302
|
-
result = af.cubic_quadratic(x_train)
|
303
|
-
|
304
|
-
#elif activation == 'exp_cubic':
|
305
|
-
#result = af.exp_cubic(x_train)
|
306
|
-
|
307
260
|
elif activation == 'sine_square':
|
308
261
|
result = af.sine_square(x_train)
|
309
262
|
|
310
263
|
elif activation == 'logarithmic':
|
311
264
|
result = af.logarithmic(x_train)
|
312
265
|
|
313
|
-
elif activation == 'scaled_cubic':
|
314
|
-
result = af.scaled_cubic(x_train, 1.0)
|
315
|
-
|
316
266
|
elif activation == 'sine_offset':
|
317
267
|
result = af.sine_offset(x_train, 1.0)
|
318
268
|
|
@@ -325,35 +275,39 @@ def draw_activations(x_train, activation):
|
|
325
275
|
return x_train
|
326
276
|
|
327
277
|
|
328
|
-
def plot_evaluate(x_test, y_test, y_preds,
|
278
|
+
def plot_evaluate(x_test, y_test, y_preds, model, cuda=False):
|
329
279
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
280
|
+
if not cuda:
|
281
|
+
from .metrics import metrics, confusion_matrix, roc_curve
|
282
|
+
from .data_ops import decode_one_hot
|
283
|
+
else:
|
284
|
+
from cuda.metrics import metrics, confusion_matrix, roc_curve
|
285
|
+
from cuda.data_ops import decode_one_hot
|
334
286
|
|
335
|
-
bar_format_normal = loading_bars()[0]
|
336
287
|
|
337
|
-
|
338
|
-
|
288
|
+
from ..model_ops import predict_from_memory
|
289
|
+
|
290
|
+
acc = model.accuracy
|
339
291
|
|
340
|
-
y_true =
|
341
|
-
y_preds =
|
292
|
+
y_true = decode_one_hot(y_test)
|
293
|
+
y_preds = decode_one_hot(y_preds)
|
294
|
+
|
342
295
|
Class = np.unique(decode_one_hot(y_test))
|
343
296
|
|
344
297
|
precision, recall, f1 = metrics(y_test, y_preds)
|
345
298
|
|
346
|
-
|
347
299
|
cm = confusion_matrix(y_true, y_preds, len(Class))
|
348
300
|
fig, axs = plt.subplots(2, 2, figsize=(16, 12))
|
301
|
+
fig.suptitle("Evaluation Report")
|
349
302
|
|
350
|
-
sns.heatmap(cm, annot=True, fmt='d', ax=axs[0, 0])
|
303
|
+
sns.heatmap(cm.get() if cuda else cm, annot=True, fmt='d', ax=axs[0, 0])
|
351
304
|
axs[0, 0].set_title("Confusion Matrix")
|
352
305
|
axs[0, 0].set_xlabel("Predicted Class")
|
353
306
|
axs[0, 0].set_ylabel("Actual Class")
|
354
307
|
|
355
308
|
if len(Class) == 2:
|
356
309
|
fpr, tpr, thresholds = roc_curve(y_true, y_preds)
|
310
|
+
if cuda: fpr, tpr = fpr.get(), tpr.get()
|
357
311
|
|
358
312
|
roc_auc = np.trapz(tpr, fpr)
|
359
313
|
axs[1, 0].plot(fpr, tpr, color='darkorange', lw=2, label=f'ROC curve (area = {roc_auc:.2f})')
|
@@ -380,7 +334,8 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activations):
|
|
380
334
|
|
381
335
|
|
382
336
|
fpr, tpr, thresholds = roc_curve(y_true_copy, y_preds_copy)
|
383
|
-
|
337
|
+
if cuda: fpr, tpr = fpr.get(), tpr.get()
|
338
|
+
|
384
339
|
roc_auc = np.trapz(tpr, fpr)
|
385
340
|
axs[1, 0].plot(fpr, tpr, color='darkorange', lw=2, label=f'ROC curve (area = {roc_auc:.2f})')
|
386
341
|
axs[1, 0].plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
|
@@ -394,7 +349,7 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activations):
|
|
394
349
|
|
395
350
|
|
396
351
|
metric = ['Precision', 'Recall', 'F1 Score', 'Accuracy']
|
397
|
-
values = [precision, recall, f1, acc]
|
352
|
+
values = [precision, recall, f1, acc if not cuda else acc.get()]
|
398
353
|
colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728']
|
399
354
|
|
400
355
|
|
@@ -405,7 +360,7 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activations):
|
|
405
360
|
axs[0, 1].text(bar.get_x() + bar.get_width() / 2, bar.get_height() - 0.05, f'{value:.2f}',
|
406
361
|
ha='center', va='bottom', fontsize=12, color='white', weight='bold')
|
407
362
|
|
408
|
-
axs[0, 1].set_ylim(0, 1)
|
363
|
+
axs[0, 1].set_ylim(0, 1)
|
409
364
|
axs[0, 1].set_xlabel('Metrics')
|
410
365
|
axs[0, 1].set_ylabel('Score')
|
411
366
|
axs[0, 1].set_title('Precision, Recall, F1 Score, and Accuracy (Weighted)')
|
@@ -414,101 +369,102 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activations):
|
|
414
369
|
feature_indices=[0, 1]
|
415
370
|
|
416
371
|
h = .02
|
372
|
+
|
373
|
+
array_type = np if not cuda else cp
|
417
374
|
x_min, x_max = x_test[:, feature_indices[0]].min() - 1, x_test[:, feature_indices[0]].max() + 1
|
418
375
|
y_min, y_max = x_test[:, feature_indices[1]].min() - 1, x_test[:, feature_indices[1]].max() + 1
|
419
|
-
xx, yy =
|
420
|
-
|
421
|
-
|
422
|
-
grid = np.c_[xx.ravel(), yy.ravel()]
|
376
|
+
xx, yy = array_type.meshgrid(array_type.arange(x_min, x_max, h),
|
377
|
+
array_type.arange(y_min, y_max, h))
|
423
378
|
|
424
|
-
try:
|
425
379
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
Z = [None] * len(grid_full)
|
430
|
-
|
431
|
-
predict_progress = initialize_loading_bar(total=len(grid_full),leave=False,
|
432
|
-
bar_format=bar_format_normal ,desc="Predicts For Decision Boundary",ncols= 65)
|
380
|
+
grid = array_type.c_[xx.ravel(), yy.ravel()]
|
381
|
+
grid_full = array_type.zeros((grid.shape[0], x_test.shape[1]), dtype=array_type.float32)
|
382
|
+
grid_full[:, feature_indices] = grid
|
433
383
|
|
434
|
-
|
384
|
+
Z = array_type.argmax(predict_from_memory(grid_full, model=model, cuda=cuda), axis=1)
|
435
385
|
|
436
|
-
|
437
|
-
predict_progress.update(1)
|
386
|
+
Z = Z.reshape(xx.shape)
|
438
387
|
|
439
|
-
|
388
|
+
if cuda:
|
389
|
+
xx = xx.get()
|
390
|
+
yy = yy.get()
|
391
|
+
Z = Z.get()
|
392
|
+
x_test = x_test.get()
|
393
|
+
y_test_decoded = decode_one_hot(y_test).get()
|
440
394
|
|
441
|
-
|
442
|
-
|
395
|
+
else:
|
396
|
+
y_test_decoded = decode_one_hot(y_test)
|
443
397
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
398
|
+
axs[1,1].contourf(xx, yy, Z, alpha=0.8)
|
399
|
+
axs[1,1].scatter(x_test[:, feature_indices[0]], x_test[:, feature_indices[1]], c=y_test_decoded, edgecolors='k', marker='o', s=20, alpha=0.9)
|
400
|
+
axs[1,1].set_xlabel(f'Feature {0 + 1}')
|
401
|
+
axs[1,1].set_ylabel(f'Feature {1 + 1}')
|
402
|
+
axs[1,1].set_title('Decision Boundary')
|
449
403
|
|
450
|
-
except Exception as e:
|
451
|
-
print(f"Error: {e}")
|
452
404
|
|
453
405
|
plt.show()
|
454
406
|
|
455
407
|
|
456
|
-
def plot_decision_boundary(x, y, activations, W, artist=
|
457
|
-
|
458
|
-
from .model_ops import predict_model_ram
|
459
|
-
from .data_ops import decode_one_hot
|
408
|
+
def plot_decision_boundary(x, y, ax, activations, W, artist, model_type, activation_potentiation=False, cuda=False):
|
460
409
|
|
410
|
+
from model_ops import get_model_template, predict_from_memory
|
411
|
+
|
412
|
+
if not cuda:
|
413
|
+
from .data_ops import decode_one_hot
|
414
|
+
|
415
|
+
else:
|
416
|
+
from cuda.data_ops import decode_one_hot
|
417
|
+
|
461
418
|
feature_indices = [0, 1]
|
462
419
|
|
420
|
+
template_model = get_model_template()
|
421
|
+
|
422
|
+
template_model = template_model(
|
423
|
+
W,
|
424
|
+
None,
|
425
|
+
None,
|
426
|
+
activations,
|
427
|
+
None,
|
428
|
+
None,
|
429
|
+
model_type,
|
430
|
+
None,
|
431
|
+
None,
|
432
|
+
None,
|
433
|
+
None,
|
434
|
+
activation_potentiation)
|
463
435
|
h = .02
|
436
|
+
array_type = np if not cuda else cp
|
464
437
|
x_min, x_max = x[:, feature_indices[0]].min() - 1, x[:, feature_indices[0]].max() + 1
|
465
438
|
y_min, y_max = x[:, feature_indices[1]].min() - 1, x[:, feature_indices[1]].max() + 1
|
466
|
-
xx, yy =
|
467
|
-
|
468
|
-
|
469
|
-
grid =
|
470
|
-
grid_full =
|
439
|
+
xx, yy = array_type.meshgrid(array_type.arange(x_min, x_max, h),
|
440
|
+
array_type.arange(y_min, y_max, h))
|
441
|
+
|
442
|
+
grid = array_type.c_[xx.ravel(), yy.ravel()]
|
443
|
+
grid_full = array_type.zeros((grid.shape[0], x.shape[1]), dtype=array_type.float32)
|
471
444
|
grid_full[:, feature_indices] = grid
|
472
|
-
|
473
|
-
Z = [None] * len(grid_full)
|
474
445
|
|
475
|
-
|
476
|
-
Z[i] = np.argmax(predict_model_ram(grid_full[i], W=W, activations=activations))
|
446
|
+
Z = array_type.argmax(predict_from_memory(grid_full, model=template_model, cuda=cuda), axis=1)
|
477
447
|
|
478
|
-
Z = np.array(Z, dtype=np.int32)
|
479
448
|
Z = Z.reshape(xx.shape)
|
480
449
|
|
481
|
-
if
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
plt.title('Decision Boundary')
|
488
|
-
|
489
|
-
plt.show()
|
450
|
+
if cuda:
|
451
|
+
xx = xx.get()
|
452
|
+
yy = yy.get()
|
453
|
+
Z = Z.get()
|
454
|
+
x = x.get()
|
455
|
+
y_test_decoded = decode_one_hot(y).get()
|
490
456
|
|
491
457
|
else:
|
458
|
+
y_test_decoded = decode_one_hot(y)
|
492
459
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
return art1_1, art1_2
|
501
|
-
|
502
|
-
except:
|
460
|
+
art1_1 = ax.contourf(xx, yy, Z, alpha=0.8)
|
461
|
+
art1_2 = ax.scatter(x[:, feature_indices[0]], x[:, feature_indices[1]], c=y_test_decoded, edgecolors='k', marker='o', s=20, alpha=0.9)
|
462
|
+
ax.set_xlabel(f'Feature {0 + 1}')
|
463
|
+
ax.set_ylabel(f'Feature {1 + 1}')
|
464
|
+
ax.set_title('Decision Boundary')
|
465
|
+
artist.append([*art1_1.collections, art1_2])
|
503
466
|
|
504
|
-
|
505
|
-
art1_2 = ax.scatter(x[:, feature_indices[0]], x[:, feature_indices[1]], c=decode_one_hot(y), edgecolors='k', marker='o', s=20, alpha=0.9)
|
506
|
-
ax.set_xlabel(f'Feature {0 + 1}')
|
507
|
-
ax.set_ylabel(f'Feature {1 + 1}')
|
508
|
-
ax.set_title('Decision Boundary')
|
509
|
-
|
510
|
-
|
511
|
-
return art1_1, art1_2
|
467
|
+
return artist
|
512
468
|
|
513
469
|
|
514
470
|
def plot_decision_space(x, y, y_preds=None, s=100, color='tab20'):
|
@@ -823,4 +779,16 @@ def display_visualizations_for_learner(viz_objects, best_weights, data, best_acc
|
|
823
779
|
|
824
780
|
ani5 = ArtistAnimation(web['fig'], web['artists'], interval=interval, blit=True)
|
825
781
|
plt.tight_layout()
|
826
|
-
plt.show()
|
782
|
+
plt.show()
|
783
|
+
|
784
|
+
|
785
|
+
def display_decision_boundary_history(fig, artist, interval):
|
786
|
+
|
787
|
+
ani1 = ArtistAnimation(fig, artist, interval=interval, blit=True)
|
788
|
+
plt.tight_layout()
|
789
|
+
plt.show()
|
790
|
+
|
791
|
+
|
792
|
+
def create_decision_boundary_hist():
|
793
|
+
fig, ax = plt.subplots()
|
794
|
+
return fig, ax
|
pyerualjetwork/cuda/__init__.py
CHANGED
@@ -6,12 +6,9 @@ The modules contained in this folder and their functions compute data on a graph
|
|
6
6
|
Modules in the folder:
|
7
7
|
----------------------
|
8
8
|
- activation_functions
|
9
|
-
-
|
10
|
-
- ene
|
9
|
+
- data_ops
|
11
10
|
- loss_functions
|
12
11
|
- metrics
|
13
|
-
- model_operations
|
14
|
-
- nn
|
15
12
|
- visualizations
|
16
13
|
|
17
14
|
Examples: https://github.com/HCB06/PyerualJetwork/tree/main/Welcome_to_PyerualJetwork/ExampleCodes
|
@@ -121,6 +121,9 @@ def sin_plus(x):
|
|
121
121
|
def modular_circular_activation(x, period=2*cp.pi):
|
122
122
|
return cp.mod(x, period) / period
|
123
123
|
|
124
|
+
def gelu(x):
|
125
|
+
return 0.5 * x * (1 + cp.tanh(cp.sqrt(2 / cp.pi) * (x + 0.044715 * cp.power(x, 3))))
|
126
|
+
|
124
127
|
def tanh_circular_activation(x):
|
125
128
|
return (cp.tanh(x) + 1) / 2
|
126
129
|
|
pyerualjetwork/cuda/data_ops.py
CHANGED
@@ -113,7 +113,7 @@ def split(X, y, test_size, random_state=42, dtype=cp.float32, shuffle_in_cpu=Fal
|
|
113
113
|
Returns:
|
114
114
|
tuple: x_train, x_test, y_train, y_test as ordered training and testing data subsets.
|
115
115
|
"""
|
116
|
-
from
|
116
|
+
from memory_ops import transfer_to_gpu, optimize_labels
|
117
117
|
|
118
118
|
X = transfer_to_gpu(X, dtype=dtype)
|
119
119
|
y = optimize_labels(y, one_hot_encoded=False, cuda=True)
|