pyerualjetwork 4.6.8b0__py3-none-any.whl → 4.6.9__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.
@@ -1,4 +1,4 @@
1
- __version__ = "4.6.8b0"
1
+ __version__ = "4.6.9"
2
2
  __update__ = """* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES
3
3
  * PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main
4
4
  * PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
@@ -421,7 +421,7 @@ def normalization(
421
421
 
422
422
  def non_neg_normalization(
423
423
  Input,
424
- dtype=np.float32
424
+ dtype=cp.float32
425
425
  ):
426
426
  """
427
427
  Normalizes the input data [0-1] range.
@@ -431,6 +431,10 @@ def non_neg_normalization(
431
431
  Returns:
432
432
  (cupy) Scaled input data after normalization.
433
433
  """
434
+
435
+ if isinstance(Input, np.ndarray):
436
+ Input = cp.array(Input, dtype=dtype)
437
+
434
438
  Input = Input.astype(dtype, copy=False)
435
439
  MaxAbs = cp.max(cp.abs(Input))
436
440
 
@@ -59,6 +59,12 @@ def save_model(model_name,
59
59
  if model_type != 'PLAN' and model_type != 'MLP':
60
60
  raise ValueError("model_type parameter must be 'PLAN' or 'MLP'.")
61
61
 
62
+ if isinstance(W, list):
63
+ W = W.copy()
64
+
65
+ if isinstance(W, np.ndarray):
66
+ W = np.copy(W)
67
+
62
68
  if isinstance(activation_potentiation, str):
63
69
  activation_potentiation = [activation_potentiation]
64
70
  else:
@@ -93,6 +99,12 @@ def save_model(model_name,
93
99
  sys.exit()
94
100
 
95
101
  elif model_type == 'MLP':
102
+
103
+ for i in range(len(W)):
104
+ W[i] = W[i].get()
105
+
106
+ W = np.array(W, dtype=object)
107
+
96
108
  class_count = W[-1].shape[0]
97
109
 
98
110
  NeuronCount.append(cp.shape(W[0])[1])
@@ -155,55 +167,50 @@ def save_model(model_name,
155
167
  df = pd.DataFrame(data)
156
168
  df.to_pickle(model_path + model_name + '.pkl')
157
169
 
158
- try:
159
170
 
160
- if weights_type == 'txt' and weights_format == 'f':
171
+ if weights_type == 'txt' and weights_format == 'f':
161
172
 
162
- cp.savetxt(model_path + model_name + f'_weights.txt', W, fmt='%f')
173
+ cp.savetxt(model_path + model_name + f'_weights.txt', W, fmt='%f')
163
174
 
164
- if weights_type == 'txt' and weights_format == 'raw':
175
+ if weights_type == 'txt' and weights_format == 'raw':
165
176
 
166
- cp.savetxt(model_path + model_name + f'_weights.txt', W)
177
+ cp.savetxt(model_path + model_name + f'_weights.txt', W)
167
178
 
168
- ###
179
+ ###
169
180
 
170
-
171
- if weights_type == 'pkl' and weights_format == 'f':
172
-
173
- with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
174
- pickle.dump(W.astype(float), f)
181
+
182
+ if weights_type == 'pkl' and weights_format == 'f':
175
183
 
176
- if weights_type == 'pkl' and weights_format =='raw':
177
-
178
- with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
179
- pickle.dump(W, f)
184
+ with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
185
+ pickle.dump(W.astype(float), f)
180
186
 
181
- ###
187
+ if weights_type == 'pkl' and weights_format =='raw':
188
+
189
+ with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
190
+ pickle.dump(W, f)
182
191
 
183
- if weights_type == 'npy' and weights_format == 'f':
192
+ ###
184
193
 
185
- cp.save(model_path + model_name + f'_weights.npy', W, W.astype(float))
194
+ if weights_type == 'npy' and weights_format == 'f':
186
195
 
187
- if weights_type == 'npy' and weights_format == 'raw':
196
+ cp.save(model_path + model_name + f'_weights.npy', W, W.astype(float))
188
197
 
189
- cp.save(model_path + model_name + f'_weights.npy', W)
198
+ if weights_type == 'npy' and weights_format == 'raw':
190
199
 
191
- ###
200
+ cp.save(model_path + model_name + f'_weights.npy', W)
192
201
 
193
- if weights_type == 'mat' and weights_format == 'f':
202
+ ###
194
203
 
195
- w = {'w': W.astype(float)}
196
- io.savemat(model_path + model_name + f'_weights.mat', w)
204
+ if weights_type == 'mat' and weights_format == 'f':
197
205
 
198
- if weights_type == 'mat' and weights_format == 'raw':
199
-
200
- w = {'w': W}
201
- io.savemat(model_path + model_name + f'_weights.mat', w)
206
+ w = {'w': W.astype(float)}
207
+ io.savemat(model_path + model_name + f'_weights.mat', w)
202
208
 
203
- except:
209
+ if weights_type == 'mat' and weights_format == 'raw':
210
+
211
+ w = {'w': W}
212
+ io.savemat(model_path + model_name + f'_weights.mat', w)
204
213
 
205
- print(Fore.RED + "ERROR: Model Weights not saved. Check the Weight parameters. SaveFilePath expl: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: save_model" + Style.RESET_ALL)
206
- sys.exit()
207
214
 
208
215
  if show_info:
209
216
  print(df)
@@ -58,7 +58,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
58
58
  and normalized using the `normalization()` function. (Max abs normalization.)
59
59
  """
60
60
  if hidden > 0:
61
- population_weights = cp.empty((population_size, hidden + 1), dtype=object)
61
+ population_weights = [[0] * (hidden + 1) for _ in range(population_size)]
62
62
  population_activations = [[0] * (hidden) for _ in range(population_size)]
63
63
 
64
64
  if len(neurons) != hidden:
@@ -88,6 +88,8 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
88
88
  population_weights[i][l][j,:] = apply_activation(population_weights[i][l][j,:], population_activations[i])
89
89
  population_weights[i][l][j,:] = normalization(population_weights[i][l][j,:], dtype=dtype)
90
90
 
91
+ return population_weights, population_activations
92
+
91
93
  else:
92
94
  population_weights = [0] * population_size
93
95
  population_activations = [0] * population_size
@@ -107,8 +109,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
107
109
  population_weights[i][j,:] = apply_activation(population_weights[i][j,:], population_activations[i])
108
110
  population_weights[i][j,:] = normalization(population_weights[i][j,:], dtype=dtype)
109
111
 
110
- return population_weights, population_activations
111
-
112
+ return cp.array(population_weights, dtype=dtype), population_activations
112
113
 
113
114
  def evolver(weights,
114
115
  activation_potentiations,
@@ -313,6 +314,16 @@ def evolver(weights,
313
314
  activation_selection_add_prob = 0
314
315
  activation_mutate_delete_prob = 0
315
316
 
317
+ if isinstance(weights, list):
318
+
319
+ for i in range(len(weights)):
320
+
321
+ for j in range(len(weights[i])):
322
+
323
+ weights[i][j] = weights[i][j].get()
324
+
325
+ weights = np.array(weights, dtype=object)
326
+
316
327
  ### FITNESS LIST IS SORTED IN ASCENDING ORDER, AND THE WEIGHT AND ACTIVATIONS OF EACH GENOME ARE SORTED ACCORDING TO THIS ORDER:
317
328
 
318
329
  sort_indices = cp.argsort(fitness)
@@ -332,7 +343,7 @@ def evolver(weights,
332
343
  bad_activations = list(activation_potentiations[:slice_center])
333
344
  best_activations = good_activations[-1].copy() if isinstance(good_activations[-1], list) else good_activations[-1]
334
345
 
335
-
346
+
336
347
  ### PLANEAT IS APPLIED ACCORDING TO THE SPECIFIED POLICY, STRATEGY, AND PROBABILITY CONFIGURATION:
337
348
 
338
349
  bar_format = loading_bars()[0]
@@ -374,8 +385,8 @@ def evolver(weights,
374
385
  else:
375
386
  act_l = l - 1
376
387
 
377
- child_W[i][l], child_act[i][act_l] = cross_over(first_parent_W[l],
378
- second_parent_W[l],
388
+ child_W[i][l], child_act[i][act_l] = cross_over(cp.array(first_parent_W[l]),
389
+ cp.array(second_parent_W[l]),
379
390
  first_parent_act[act_l],
380
391
  second_parent_act[act_l],
381
392
  cross_over_mode=cross_over_mode,
@@ -389,6 +400,8 @@ def evolver(weights,
389
400
  weight_evolve=weight_evolve,
390
401
  epsilon=epsilon
391
402
  )
403
+
404
+
392
405
  else:
393
406
  child_W[i], child_act[i] = cross_over(first_parent_W,
394
407
  second_parent_W,
@@ -428,7 +441,7 @@ def evolver(weights,
428
441
  else:
429
442
  act_l = l - 1
430
443
 
431
- mutated_W[i][l], mutated_act[i][act_l] = mutation(genome_W[l],
444
+ mutated_W[i][l], mutated_act[i][act_l] = mutation(cp.array(genome_W[l]),
432
445
  genome_act[act_l],
433
446
  activation_mutate_prob=activation_mutate_prob,
434
447
  activation_add_prob=activation_mutate_add_prob,
@@ -462,7 +475,13 @@ def evolver(weights,
462
475
  child_act[0] = best_activations
463
476
 
464
477
  if is_mlp:
465
- weights = cp.vstack((child_W, mutated_W), dtype=object)
478
+ for i in range(len(child_W)):
479
+ for j in range(len(child_W[i])):
480
+ child_W[i][j] = cp.array(child_W[i][j], dtype=dtype)
481
+
482
+ child_W = list(child_W)
483
+ mutated_W = list(mutated_W)
484
+ weights = child_W + mutated_W
466
485
  else:
467
486
  weights = cp.vstack((child_W, mutated_W), dtype=dtype)
468
487
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.6.8b0
3
+ Version: 4.6.9
4
4
  Summary: PyerualJetwork is a machine learning library supported with GPU(CUDA) acceleration written in Python for professionals and researchers including with PLAN algorithm, PLANEAT algorithm (genetic optimization). Also includes data pre-process and memory manegament
5
5
  Author: Hasan Can Beydili
6
6
  Author-email: tchasancan@gmail.com
@@ -1,8 +1,8 @@
1
- pyerualjetwork/__init__.py,sha256=u-vA_SDH_vmQI2fEUzbCFlIJG84uHxcir0gEXc-UvgQ,1281
1
+ pyerualjetwork/__init__.py,sha256=dHKy0qs8k0WJK90YYsm9b-cMzeHViFH3rpY8M7TYh2g,1279
2
2
  pyerualjetwork/activation_functions.py,sha256=0fNOHXd490HC6gadKwb0AuBjw34dWq3GRZkg5iWO27c,7621
3
3
  pyerualjetwork/activation_functions_cuda.py,sha256=X5-dtYBkGp35kyL21eLR7mbYUdttxElu-WqXmwmkV9E,7672
4
4
  pyerualjetwork/data_operations.py,sha256=XKYG9-mLa3qKAXUjejuD7V8aJKjpl5PdQwKzPFjpKgs,15437
5
- pyerualjetwork/data_operations_cuda.py,sha256=zqiHXDRtC8qDlVlN6lLoZn9uQgkm40aKFfFjWjurCxQ,17538
5
+ pyerualjetwork/data_operations_cuda.py,sha256=REvZxtxcKmQNy2wekkbUOVi2Fg1VV9tomi2_ykXWXsM,17627
6
6
  pyerualjetwork/fitness_functions.py,sha256=urRdeMvUhNgWxD4ZGHCRdQlIf9cTWYMvF3_aVBojRqY,1235
7
7
  pyerualjetwork/help.py,sha256=nQ_YbYA2RtuafhuvkreNpX0WWL1I_nzlelwCtvei0_Y,775
8
8
  pyerualjetwork/loss_functions.py,sha256=6PyBI232SQRGuFnG3LDGvnv_PUdWzT2_2mUODJiejGI,618
@@ -11,15 +11,15 @@ pyerualjetwork/memory_operations.py,sha256=0yCOHcgiNyF4ccMcRlL1Q9F_byG4nzjhmkbpX
11
11
  pyerualjetwork/metrics.py,sha256=q7MkhnZDRbCjFBDDfUgrl8lBYnUT_1ro1LxeBq105pI,6077
12
12
  pyerualjetwork/metrics_cuda.py,sha256=73h9GC7XwmnFCVzFEEiPQfF8CwHIz2wsCbxpZrJtYgw,5061
13
13
  pyerualjetwork/model_operations.py,sha256=SYMXYNFFLz2YUvmp9lSKXd2L1vCwhyL_AUjL3UYCkZw,15134
14
- pyerualjetwork/model_operations_cuda.py,sha256=GE_71JLTItAFXz8iW60QeO4XKJ8fGeHgxETmHtW9drc,16204
14
+ pyerualjetwork/model_operations_cuda.py,sha256=VmFtzuSs37FUIWeEML229hTHeZzSFPNBleI7qDfCOV0,16096
15
15
  pyerualjetwork/plan.py,sha256=cjVblo8TxTHX-GZPvgQvJZ34nOmzxSvtCrQi9K-Mhog,23268
16
16
  pyerualjetwork/plan_cuda.py,sha256=ZEU_b_EoA-zPk7Gn94L_XBZz1v4mn8DOUsjTNV6fp8Q,24230
17
17
  pyerualjetwork/planeat.py,sha256=prbkUIrD37Y_b7MmTuGg4rGHXfqHIjLFMbs7TnnEy9E,44645
18
- pyerualjetwork/planeat_cuda.py,sha256=i6WDHkUEAMK7IHNBilM29xyYWq2qvPNpF9idcAkC1EU,44650
18
+ pyerualjetwork/planeat_cuda.py,sha256=Yrf9DDLN1gHXQE8-ZKnWOWShu0Yxt4WX1ued0m6d10w,45239
19
19
  pyerualjetwork/ui.py,sha256=JBTFYz5R24XwNKhA3GSW-oYAoiIBxAE3kFGXkvm5gqw,656
20
20
  pyerualjetwork/visualizations.py,sha256=utnX9zQhzmtvBJLOLNGm2jecVVk4zHXABQdjb0XzJac,28352
21
21
  pyerualjetwork/visualizations_cuda.py,sha256=gnoaaazZ-nc9E1ImqXrZBRgQ4Rnpi2qh2yGJ2eLKMlE,28807
22
- pyerualjetwork-4.6.8b0.dist-info/METADATA,sha256=nB7S7mpl1snTt4T8QzTSs8ShpPEpny_at6JXeqW5h2c,7507
23
- pyerualjetwork-4.6.8b0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
- pyerualjetwork-4.6.8b0.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
25
- pyerualjetwork-4.6.8b0.dist-info/RECORD,,
22
+ pyerualjetwork-4.6.9.dist-info/METADATA,sha256=rbHWRN5oXx_j3qL6f4Y57AJTNeU0sAZPGIgo3cpPJlg,7505
23
+ pyerualjetwork-4.6.9.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
+ pyerualjetwork-4.6.9.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
25
+ pyerualjetwork-4.6.9.dist-info/RECORD,,