pyerualjetwork 5.57a2__py3-none-any.whl → 5.57a4__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 +1 -1
- pyerualjetwork/memory_ops.py +0 -82
- pyerualjetwork/nn.py +10 -30
- {pyerualjetwork-5.57a2.dist-info → pyerualjetwork-5.57a4.dist-info}/METADATA +1 -1
- {pyerualjetwork-5.57a2.dist-info → pyerualjetwork-5.57a4.dist-info}/RECORD +7 -7
- {pyerualjetwork-5.57a2.dist-info → pyerualjetwork-5.57a4.dist-info}/WHEEL +0 -0
- {pyerualjetwork-5.57a2.dist-info → pyerualjetwork-5.57a4.dist-info}/top_level.txt +0 -0
pyerualjetwork/__init__.py
CHANGED
@@ -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.57a4"
|
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
|
pyerualjetwork/memory_ops.py
CHANGED
@@ -28,88 +28,6 @@ import psutil
|
|
28
28
|
import numpy as np
|
29
29
|
import cupy as cp
|
30
30
|
import logging
|
31
|
-
from multiprocessing import shared_memory
|
32
|
-
|
33
|
-
x_train_shape = None
|
34
|
-
y_train_shape = None
|
35
|
-
x_train_dtype = None
|
36
|
-
y_train_dtype = None
|
37
|
-
x_shm_name = None
|
38
|
-
y_shm_name = None
|
39
|
-
|
40
|
-
|
41
|
-
def batcher_worker(index, batcher_fn):
|
42
|
-
"""
|
43
|
-
Shared memory ile batcher çalıştıran worker.
|
44
|
-
|
45
|
-
:param index: Batch indexi
|
46
|
-
:param batcher_fn: batcher fonksiyonu (örneğin: def batcher(x, y): ...)
|
47
|
-
:return: (x_batch, y_batch)
|
48
|
-
"""
|
49
|
-
existing_x = shared_memory.SharedMemory(name=x_shm_name)
|
50
|
-
existing_y = shared_memory.SharedMemory(name=y_shm_name)
|
51
|
-
|
52
|
-
x_np = np.ndarray(x_train_shape, dtype=x_train_dtype, buffer=existing_x.buf)
|
53
|
-
y_np = np.ndarray(y_train_shape, dtype=y_train_dtype, buffer=existing_y.buf)
|
54
|
-
|
55
|
-
result = batcher_fn(x_np, y_np)
|
56
|
-
|
57
|
-
existing_x.close()
|
58
|
-
existing_y.close()
|
59
|
-
return result
|
60
|
-
|
61
|
-
|
62
|
-
def cleanup_shared_memory(x_shm, y_shm):
|
63
|
-
"""
|
64
|
-
Shared memory nesnelerini kapatır ve belleği serbest bırakır.
|
65
|
-
"""
|
66
|
-
x_shm.close()
|
67
|
-
x_shm.unlink()
|
68
|
-
y_shm.close()
|
69
|
-
y_shm.unlink()
|
70
|
-
|
71
|
-
def evaluate_worker(params, evaluate_fn):
|
72
|
-
"""
|
73
|
-
Shared memory kullanan evaluate fonksiyonu için wrapper.
|
74
|
-
|
75
|
-
:param params: evaluate fonksiyonuna gidecek parametreler
|
76
|
-
:param evaluate_fn: evaluate fonksiyonu
|
77
|
-
:return: evaluate sonucu
|
78
|
-
"""
|
79
|
-
return evaluate_fn(*params)
|
80
|
-
|
81
|
-
|
82
|
-
def plan_fit_worker(params, plan_fit_fn):
|
83
|
-
"""
|
84
|
-
Shared memory kullanan plan_fit fonksiyonu için wrapper.
|
85
|
-
|
86
|
-
:param params: plan_fit fonksiyonuna gidecek parametreler
|
87
|
-
:param plan_fit_fn: plan_fit fonksiyonu
|
88
|
-
:return: plan_fit sonucu
|
89
|
-
"""
|
90
|
-
return plan_fit_fn(*params)
|
91
|
-
|
92
|
-
def loss_worker(params, loss_fn):
|
93
|
-
"""
|
94
|
-
Shared memory kullanan loss fonksiyonu için wrapper.
|
95
|
-
|
96
|
-
:param params: (y_true_batch, y_pred_batch)
|
97
|
-
:param loss_fn: categorical_crossentropy veya binary_crossentropy
|
98
|
-
:return: loss sonucu
|
99
|
-
"""
|
100
|
-
return loss_fn(*params)
|
101
|
-
|
102
|
-
|
103
|
-
def fitness_worker(params, fitness_fn):
|
104
|
-
"""
|
105
|
-
Shared memory kullanan fitness (örn. wals) fonksiyonu için wrapper.
|
106
|
-
|
107
|
-
:param params: (acc, loss, acc_impact, loss_impact)
|
108
|
-
:param fitness_fn: fitness fonksiyonu
|
109
|
-
:return: fitness skoru
|
110
|
-
"""
|
111
|
-
return fitness_fn(*params)
|
112
|
-
|
113
31
|
|
114
32
|
def get_available_cpu_memory():
|
115
33
|
"""
|
pyerualjetwork/nn.py
CHANGED
@@ -51,22 +51,20 @@ import numpy as np
|
|
51
51
|
import cupy as cp
|
52
52
|
import copy
|
53
53
|
import random
|
54
|
-
|
55
|
-
import
|
56
|
-
from functools import partial
|
54
|
+
import multiprocessing
|
55
|
+
from multiprocessing import Pool, cpu_count
|
57
56
|
|
58
57
|
### LIBRARY IMPORTS ###
|
59
58
|
from .ui import loading_bars, initialize_loading_bar
|
60
59
|
from .cpu.activation_functions import all_activations
|
61
60
|
from .model_ops import get_acc, get_preds_softmax, get_preds
|
62
|
-
import
|
63
|
-
from .memory_ops import optimize_labels, transfer_to_gpu, batcher_worker, cleanup_shared_memory, plan_fit_worker, fitness_worker, loss_worker, evaluate_worker
|
61
|
+
from .memory_ops import optimize_labels, transfer_to_gpu
|
64
62
|
from .fitness_functions import wals
|
65
63
|
|
66
64
|
### GLOBAL VARIABLES ###
|
65
|
+
bar_format_normal = loading_bars()[0]
|
67
66
|
bar_format_learner = loading_bars()[1]
|
68
67
|
|
69
|
-
|
70
68
|
# BUILD -----
|
71
69
|
|
72
70
|
def plan_fit(
|
@@ -366,30 +364,12 @@ def learn(x_train, y_train, optimizer, gen, pop_size, fit_start=True, batch_size
|
|
366
364
|
|
367
365
|
if parallel_training:
|
368
366
|
|
369
|
-
x_shm = shared_memory.SharedMemory(create=True, size=x_train.nbytes)
|
370
|
-
y_shm = shared_memory.SharedMemory(create=True, size=y_train.nbytes)
|
371
|
-
|
372
|
-
# Kopyalama shared memory alanına
|
373
|
-
np.copyto(np.ndarray(x_train.shape, dtype=x_train.dtype, buffer=x_shm.buf), x_train)
|
374
|
-
np.copyto(np.ndarray(y_train.shape, dtype=y_train.dtype, buffer=y_shm.buf), y_train)
|
375
|
-
|
376
|
-
# memory_ops modülüne metadata aktar
|
377
|
-
memory_ops.x_shm_name = x_shm.name
|
378
|
-
memory_ops.y_shm_name = y_shm.name
|
379
|
-
memory_ops.x_train_shape = x_train.shape
|
380
|
-
memory_ops.y_train_shape = y_train.shape
|
381
|
-
memory_ops.x_train_dtype = x_train.dtype
|
382
|
-
memory_ops.y_train_dtype = y_train.dtype
|
383
|
-
|
384
|
-
# Bellek temizliği için register
|
385
|
-
atexit.register(lambda: cleanup_shared_memory(x_shm, y_shm))
|
386
|
-
|
387
367
|
eval_params = []
|
388
368
|
fit_params = []
|
389
369
|
|
390
370
|
with Pool(processes=thread_count) as pool:
|
391
|
-
|
392
|
-
batches =
|
371
|
+
|
372
|
+
batches = batcher(x_train, y_train, batch_size)
|
393
373
|
|
394
374
|
eval_params = [
|
395
375
|
(
|
@@ -408,7 +388,7 @@ def learn(x_train, y_train, optimizer, gen, pop_size, fit_start=True, batch_size
|
|
408
388
|
if start_this_act is not None and i == 0:
|
409
389
|
w_copy = copy.deepcopy(weight_pop[0])
|
410
390
|
|
411
|
-
W = pool.
|
391
|
+
W = pool.starmap(plan_fit, fit_params)
|
412
392
|
new_weights = W
|
413
393
|
|
414
394
|
eval_params = [
|
@@ -423,14 +403,14 @@ def learn(x_train, y_train, optimizer, gen, pop_size, fit_start=True, batch_size
|
|
423
403
|
eval_params[0][8], eval_params[0][9]
|
424
404
|
)
|
425
405
|
|
426
|
-
models = pool.
|
406
|
+
models = pool.starmap(evaluate, eval_params)
|
427
407
|
|
428
408
|
y_preds = [model[get_preds_softmax()] for model in models]
|
429
409
|
loss_params = [(eval_params[f][1], y_preds[f]) for f in range(pop_size)]
|
430
410
|
loss_func = categorical_crossentropy if loss == 'categorical_crossentropy' else binary_crossentropy
|
431
|
-
losses = pool.
|
411
|
+
losses = pool.starmap(loss_func, loss_params)
|
432
412
|
fitness_params = [(models[f][get_acc()], losses[f], acc_impact, loss_impact) for f in range(pop_size)]
|
433
|
-
target_pop = pool.
|
413
|
+
target_pop = pool.starmap(wals, fitness_params)
|
434
414
|
|
435
415
|
if cuda:
|
436
416
|
target_pop = [fit.get() for fit in target_pop]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyerualjetwork
|
3
|
-
Version: 5.
|
3
|
+
Version: 5.57a4
|
4
4
|
Summary: PyereualJetwork is a GPU-accelerated + Parallel Threading Supported 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
|
@@ -1,11 +1,11 @@
|
|
1
|
-
pyerualjetwork/__init__.py,sha256=
|
1
|
+
pyerualjetwork/__init__.py,sha256=G2leKoudcqlztYh5O9TOnHkxCqoD3Fe6pmrwrADrsQE,3089
|
2
2
|
pyerualjetwork/ene.py,sha256=luTvspHRTose6s3uRas40pNXyKoxU9siaHiMBNI5yoc,42136
|
3
3
|
pyerualjetwork/fitness_functions.py,sha256=D9JVCr9DFid_xXgBD4uCKxdW2k10MVDE5HZRSOK4Igg,1237
|
4
4
|
pyerualjetwork/help.py,sha256=sn9jBzXkQsTZvdgsUXUpSs_BbYYIgY3whofg6dj8peI,848
|
5
5
|
pyerualjetwork/issue_solver.py,sha256=uay_9XK6xWnLmK2P_BeyDQlyNXzg_zYffnXYd228wZk,4102
|
6
|
-
pyerualjetwork/memory_ops.py,sha256=
|
6
|
+
pyerualjetwork/memory_ops.py,sha256=TUFh9SYWCKL6N-vNdWId_EwU313TuZomQCHOrltrD-4,14280
|
7
7
|
pyerualjetwork/model_ops.py,sha256=WaP1XwKqXMfZl4Yop8a1Bg0xtmLYgap9JFOWHaLr7S4,25143
|
8
|
-
pyerualjetwork/nn.py,sha256=
|
8
|
+
pyerualjetwork/nn.py,sha256=szkb25UCeg6MwG49DmL7XJXbGCFgk-OzscibTBlqCuc,41385
|
9
9
|
pyerualjetwork/old_cpu_model_ops.py,sha256=1KNgjUeYCO_TsA5RtbNiuIiBJzq8-rL2dE6jxKqCBU0,21481
|
10
10
|
pyerualjetwork/old_cuda_model_ops.py,sha256=KAscAd8e_I8Vqdd9BJaHd6-IG6fhxFglAFxys0sqmEo,23079
|
11
11
|
pyerualjetwork/ui.py,sha256=JBTFYz5R24XwNKhA3GSW-oYAoiIBxAE3kFGXkvm5gqw,656
|
@@ -21,7 +21,7 @@ pyerualjetwork/cuda/data_ops.py,sha256=BEXh4M7BWXaTpYlVS9D2i3CGgOmL5131vy7FZyuTQ
|
|
21
21
|
pyerualjetwork/cuda/loss_functions.py,sha256=C93IZJcrOpT6HMK9x1O4AHJWXYTkN5WZiqdssPbvAPk,617
|
22
22
|
pyerualjetwork/cuda/metrics.py,sha256=PjDBoRvr6va8vRvDIJJGBO4-I4uumrk3NCM1Vz4NJTo,5054
|
23
23
|
pyerualjetwork/cuda/visualizations.py,sha256=2mHE7iqqsN3K6xtCnemS4o_YWGS0bIV2IxF4cG6Ur9k,20090
|
24
|
-
pyerualjetwork-5.
|
25
|
-
pyerualjetwork-5.
|
26
|
-
pyerualjetwork-5.
|
27
|
-
pyerualjetwork-5.
|
24
|
+
pyerualjetwork-5.57a4.dist-info/METADATA,sha256=GzgYQ4w0HS1BTfJAeoeInCskeaePmcQCexRN5Xg7kpI,8052
|
25
|
+
pyerualjetwork-5.57a4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
26
|
+
pyerualjetwork-5.57a4.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
|
27
|
+
pyerualjetwork-5.57a4.dist-info/RECORD,,
|
File without changes
|
File without changes
|