pyerualjetwork 4.3.8.dev3__py3-none-any.whl → 4.3.8.dev5__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.3.8dev3"
1
+ __version__ = "4.3.8dev5"
2
2
  __update__ = "* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES\n* PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main\n* PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf\n* YouTube tutorials: https://www.youtube.com/@HasanCanBeydili"
3
3
 
4
4
  def print_version(__version__):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.3.8.dev3
3
+ Version: 4.3.8.dev5
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,4 +1,4 @@
1
- pyerualjetwork/__init__.py,sha256=TigQhP6yP1luXiX5fdCVYqBZQTjPRdboBfy_KU5-g_4,643
1
+ pyerualjetwork/__init__.py,sha256=aQiVtvIoAkk7-Wrr-xNhNQPwVZB-2cSoKH8xytXVVqM,643
2
2
  pyerualjetwork/activation_functions.py,sha256=AR91fQV2W2rc-Qb4Yp7b8ucYpGjwyQUewO-M-lyEMs8,7729
3
3
  pyerualjetwork/activation_functions_cuda.py,sha256=ztIw6rMR4t1289_TPIGYwE6qarl_YbSOGj5Ep3rUMqs,11803
4
4
  pyerualjetwork/data_operations.py,sha256=Flteouu6rfSo2uHMqBHuzO02dXmbNa-I5qWmUpGTZ5Y,14760
@@ -18,7 +18,7 @@ pyerualjetwork/planeat_cuda.py,sha256=QNHCQLkR0MNFqyN2iHAtC7cbf8qZiD3p_54YH3lnMF
18
18
  pyerualjetwork/ui.py,sha256=wu2BhU1k-w3Kcho5Jtq4SEKe68ftaUeRGneUOSCVDjU,575
19
19
  pyerualjetwork/visualizations.py,sha256=VL00sX2DZz83F__PyEJH9s1LizuXpOBzWjnoSjMJIJ0,28770
20
20
  pyerualjetwork/visualizations_cuda.py,sha256=KbMhfsLlxujy_i3QrwCf734Q-k6d7Zn_7CEbm3gzK9w,29186
21
- pyerualjetwork_afterburner/__init__.py,sha256=W9d7H3PMu6MRcdGYPHpUa0q9Kx7-ogu5xLq1g928y64,655
21
+ pyerualjetwork_afterburner/__init__.py,sha256=kmFJeX5myisl9iSpmRGJPH4v51_2kcI0ZaauXjLkRCw,655
22
22
  pyerualjetwork_afterburner/activation_functions.py,sha256=bKf00lsuuLJNO-4vVp4OqBi4zJ-qZ8L3v-vl52notkY,7721
23
23
  pyerualjetwork_afterburner/activation_functions_cuda.py,sha256=5y1Ti3GDfDteQDCUmODwe7tAyDAUlDTKmIikChQ8d6g,7772
24
24
  pyerualjetwork_afterburner/data_operations.py,sha256=Flteouu6rfSo2uHMqBHuzO02dXmbNa-I5qWmUpGTZ5Y,14760
@@ -31,14 +31,14 @@ pyerualjetwork_afterburner/metrics.py,sha256=q7MkhnZDRbCjFBDDfUgrl8lBYnUT_1ro1Lx
31
31
  pyerualjetwork_afterburner/metrics_cuda.py,sha256=73h9GC7XwmnFCVzFEEiPQfF8CwHIz2wsCbxpZrJtYgw,5061
32
32
  pyerualjetwork_afterburner/model_operations.py,sha256=MCSCNYiiICRVZITobtS3ZIWmH5Q9gjyELuH32sAdgg4,12649
33
33
  pyerualjetwork_afterburner/model_operations_cuda.py,sha256=NT01BK5nrDYE7H1x3KnSI8gmx0QTGGB0mP_LqEb1uuU,13157
34
- pyerualjetwork_afterburner/plan.py,sha256=Gxv8ii4brTYMzzFZBP-X6kkwc6w6vtTPiMmqVOAqoq8,21972
34
+ pyerualjetwork_afterburner/plan.py,sha256=EOXngujG7DQRf3cooFigKB7heQsEoK96JtrcKivT_pE,22449
35
35
  pyerualjetwork_afterburner/plan_cuda.py,sha256=fg5YunEuBE7sK6q9paP_yAGONr9x0e19oF0J0DucejM,23380
36
36
  pyerualjetwork_afterburner/planeat.py,sha256=Lq5R0aMS4UIdZdbUKsKDv5g0WLwYryomR3IQYb8vAa4,37573
37
- pyerualjetwork_afterburner/planeat_cuda.py,sha256=SG7Oq1F2m3lJBbG9cgmu7q_ApmwSn2SvTpcbtEVAoDE,37630
37
+ pyerualjetwork_afterburner/planeat_cuda.py,sha256=Hh-prPlPToiJIyR3Xsp_b22cFIwEP09T77UJyZKnLLo,38722
38
38
  pyerualjetwork_afterburner/ui.py,sha256=wu2BhU1k-w3Kcho5Jtq4SEKe68ftaUeRGneUOSCVDjU,575
39
39
  pyerualjetwork_afterburner/visualizations.py,sha256=1SKMZaJ80OD2qHUyMxW1IOv8zwmxzMPxclfbeq1Xr4g,28772
40
40
  pyerualjetwork_afterburner/visualizations_cuda.py,sha256=KbMhfsLlxujy_i3QrwCf734Q-k6d7Zn_7CEbm3gzK9w,29186
41
- pyerualjetwork-4.3.8.dev3.dist-info/METADATA,sha256=VFNiB4kXQ8sU6wa_9uGjkHi_s-b-rzCY_wIJOLbnALM,8384
42
- pyerualjetwork-4.3.8.dev3.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
43
- pyerualjetwork-4.3.8.dev3.dist-info/top_level.txt,sha256=uK64ge08QQoPuXM3aiRVPgiQQtl8Fxm2-HieIut5Lwo,42
44
- pyerualjetwork-4.3.8.dev3.dist-info/RECORD,,
41
+ pyerualjetwork-4.3.8.dev5.dist-info/METADATA,sha256=4tAsoW5zkw92w30B6KZimXpYC1GIun2NWTbTenshDbs,8384
42
+ pyerualjetwork-4.3.8.dev5.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
43
+ pyerualjetwork-4.3.8.dev5.dist-info/top_level.txt,sha256=uK64ge08QQoPuXM3aiRVPgiQQtl8Fxm2-HieIut5Lwo,42
44
+ pyerualjetwork-4.3.8.dev5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
- __version__ = "4.3.8dev3-afterburner"
1
+ __version__ = "4.3.8dev5-afterburner"
2
2
  __update__ = "* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES\n* PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main\n* PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf\n* YouTube tutorials: https://www.youtube.com/@HasanCanBeydili"
3
3
 
4
4
  def print_version(__version__):
@@ -78,7 +78,7 @@ def fit(
78
78
  return normalization(LTPW, dtype=dtype)
79
79
 
80
80
 
81
- def learner(x_train, y_train, optimizer, fit_start, strategy='accuracy', gen=None, batch_size=1,
81
+ def learner(x_train, y_train, optimizer, fit_start, strategy='accuracy', gen=None, batch_size=1, pop_size=None,
82
82
  neural_web_history=False, show_current_activations=False,
83
83
  neurons_history=False, early_stop=False, loss='categorical_crossentropy', show_history=False,
84
84
  interval=33.33, target_acc=None, target_loss=None,
@@ -123,6 +123,8 @@ def learner(x_train, y_train, optimizer, fit_start, strategy='accuracy', gen=Non
123
123
 
124
124
  batch_size (float, optional): Batch size is used in the prediction process to receive train feedback by dividing the test data into chunks and selecting activations based on randomly chosen partitions. This process reduces computational cost and time while still covering the entire test set due to random selection, so it doesn't significantly impact accuracy. For example, a batch size of 0.08 means each train batch represents 8% of the train set. Default is 1. (%100 of train)
125
125
 
126
+ pop_size (int, optional): Population size of each generation. Default: count of activation functions
127
+
126
128
  early_stop (bool, optional): If True, implements early stopping during training.(If accuracy not improves in two gen stops learning.) Default is False.
127
129
 
128
130
  show_current_activations (bool, optional): Should it display the activations selected according to the current strategies during learning, or not? (True or False) This can be very useful if you want to cancel the learning process and resume from where you left off later. After canceling, you will need to view the live training activations in order to choose the activations to be given to the 'start_this' parameter. Default is False
@@ -156,14 +158,19 @@ def learner(x_train, y_train, optimizer, fit_start, strategy='accuracy', gen=Non
156
158
 
157
159
  data = 'Train'
158
160
 
159
- activation_potentiation = all_activations()
161
+ except_this = ['spiral', 'circular']
162
+ activation_potentiation = [item for item in all_activations() if item not in except_this]
160
163
  activation_potentiation_len = len(activation_potentiation)
161
164
 
162
165
  # Pre-checks
163
166
 
167
+ if pop_size is None: pop_size = activation_potentiation_len
168
+
164
169
  x_train = x_train.astype(dtype, copy=False)
165
170
  y_train = optimize_labels(y_train, cuda=False)
166
171
 
172
+ if pop_size < activation_potentiation_len: raise ValueError(f"pop_size must be higher or equal to {activation_potentiation_len}")
173
+
167
174
  if gen is None:
168
175
  gen = activation_potentiation_len
169
176
 
@@ -192,16 +199,16 @@ def learner(x_train, y_train, optimizer, fit_start, strategy='accuracy', gen=Non
192
199
 
193
200
  progress = initialize_loading_bar(total=activation_potentiation_len, desc="", ncols=ncols, bar_format=bar_format_learner)
194
201
 
195
- if fit_start is False:
196
- weight_pop, act_pop = define_genomes(input_shape=len(x_train[0]), output_shape=len(y_train[0]), population_size=activation_potentiation_len, dtype=dtype)
202
+ if fit_start is False or pop_size > activation_potentiation_len:
203
+ weight_pop, act_pop = define_genomes(input_shape=len(x_train[0]), output_shape=len(y_train[0]), population_size=pop_size, dtype=dtype)
197
204
 
198
205
  if start_this_act is not None and start_this_W is not None:
199
206
  weight_pop[0] = start_this_W
200
207
  act_pop[0] = start_this_act
201
208
 
202
209
  else:
203
- weight_pop = []
204
- act_pop = []
210
+ weight_pop = [0] * pop_size
211
+ act_pop = [0] * pop_size
205
212
 
206
213
  for i in range(gen):
207
214
  postfix_dict["Gen"] = str(i+1) + '/' + str(gen)
@@ -211,14 +218,14 @@ def learner(x_train, y_train, optimizer, fit_start, strategy='accuracy', gen=Non
211
218
  progress.last_print_n = 0
212
219
  progress.update(0)
213
220
 
214
- for j in range(activation_potentiation_len):
221
+ for j in range(pop_size):
215
222
 
216
223
  x_train_batch, y_train_batch = batcher(x_train, y_train, batch_size=batch_size)
217
224
 
218
- if fit_start is True and i == 0:
219
- act_pop.append(activation_potentiation[j])
225
+ if fit_start is True and i == 0 and j < activation_potentiation_len:
226
+ act_pop[j] = activation_potentiation[j]
220
227
  W = fit(x_train_batch, y_train_batch, activation_potentiation=act_pop[-1], dtype=dtype)
221
- weight_pop.append(W)
228
+ weight_pop[j] = W
222
229
 
223
230
  model = evaluate(x_train_batch, y_train_batch, W=weight_pop[j], activation_potentiation=act_pop[j])
224
231
  acc = model[get_acc()]
@@ -16,6 +16,8 @@ import cupy as cp
16
16
  import numpy as np
17
17
  import random
18
18
  import math
19
+ import multiprocessing as mp
20
+ from functools import partial
19
21
 
20
22
 
21
23
  ### LIBRARY IMPORTS ###
@@ -296,64 +298,31 @@ def evolver(weights,
296
298
  mutated_W = cp.copy(bad_weights)
297
299
  mutated_act = bad_activations.copy()
298
300
 
299
-
300
- for i in range(len(bad_weights)):
301
-
302
- if policy == 'aggressive':
303
- first_parent_W = best_weight
304
- first_parent_act = best_activations
305
-
306
- elif policy == 'explorer':
307
- first_parent_W = good_weights[i]
308
- first_parent_act = good_activations[i]
309
-
310
- else: raise ValueError("policy parameter must be: 'aggressive' or 'explorer'")
311
-
312
- second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
313
-
314
- child_W[i], child_act[i] = cross_over(first_parent_W,
315
- second_parent_W,
316
- first_parent_act,
317
- second_parent_act,
318
- cross_over_mode=cross_over_mode,
319
- activation_selection_add_prob=activation_selection_add_prob,
320
- activation_selection_change_prob=activation_selection_change_prob,
321
- activation_selection_threshold=activation_selection_threshold,
322
- bad_genomes_selection_prob=bad_genomes_selection_prob,
323
- first_parent_fitness=best_fitness,
324
- fitness_bias=fitness_bias,
325
- second_parent_fitness=normalized_fitness[s_i],
326
- epsilon=epsilon
327
- )
328
-
329
- mutation_prob = random.uniform(0, 1)
330
-
331
- if mutation_prob > bad_genomes_mutation_prob:
332
- genome_W = good_weights[i]
333
- genome_act = good_activations[i]
334
-
335
- fitness_index = int(len(bad_weights) / 2 + i)
336
-
337
- else:
338
- genome_W = bad_weights[i]
339
- genome_act = bad_activations[i]
340
-
341
- fitness_index = i
342
-
343
- mutated_W[i], mutated_act[i] = mutation(genome_W,
344
- genome_act,
345
- activation_mutate_prob=activation_mutate_prob,
346
- activation_add_prob=activation_mutate_add_prob,
347
- activation_delete_prob=activation_mutate_delete_prob,
348
- activation_change_prob=activation_mutate_change_prob,
349
- weight_mutate_prob=weight_mutate_prob,
350
- weight_mutate_threshold=weight_mutate_threshold,
351
- genome_fitness=normalized_fitness[fitness_index],
352
- activation_mutate_threshold=activation_mutate_threshold,
353
- epsilon=epsilon
354
- )
355
-
356
- if bar_status: progress.update(1)
301
+ with mp.Pool() as pool:
302
+ process_func = partial(process_single, policy=policy, best_weight=best_weight,
303
+ best_activations=best_activations, good_weights=good_weights,
304
+ good_activations=good_activations, bad_weights=bad_weights,
305
+ bad_activations=bad_activations, best_fitness=best_fitness,
306
+ normalized_fitness=normalized_fitness, child_W=child_W,
307
+ child_act=child_act, mutated_W=mutated_W, mutated_act=mutated_act,
308
+ progress=progress, bar_status=bar_status,
309
+ cross_over_mode=cross_over_mode,
310
+ activation_selection_add_prob=activation_selection_add_prob,
311
+ activation_selection_change_prob=activation_selection_change_prob,
312
+ activation_selection_threshold=activation_selection_threshold,
313
+ bad_genomes_selection_prob=bad_genomes_selection_prob,
314
+ fitness_bias=fitness_bias,
315
+ epsilon=epsilon,
316
+ bad_genomes_mutation_prob=bad_genomes_mutation_prob,
317
+ activation_mutate_prob=activation_mutate_prob,
318
+ activation_mutate_add_prob=activation_mutate_add_prob,
319
+ activation_mutate_delete_prob=activation_mutate_delete_prob,
320
+ activation_mutate_change_prob=activation_mutate_change_prob,
321
+ weight_mutate_prob=weight_mutate_prob,
322
+ weight_mutate_threshold=weight_mutate_threshold,
323
+ activation_mutate_threshold=activation_mutate_threshold)
324
+
325
+ pool.map(process_func, range(len(bad_weights)))
357
326
 
358
327
  child_W[0] = best_weight
359
328
  child_act[0] = best_activations
@@ -398,6 +367,40 @@ def evolver(weights,
398
367
  return weights, activation_potentiations
399
368
 
400
369
 
370
+ def process_single(i, policy, best_weight, best_activations, good_weights, good_activations,
371
+ bad_weights, bad_activations, best_fitness, normalized_fitness, child_W, child_act,
372
+ mutated_W, mutated_act, progress, bar_status, cross_over_mode,
373
+ activation_selection_add_prob, activation_selection_change_prob,
374
+ activation_selection_threshold, bad_genomes_selection_prob, fitness_bias,
375
+ epsilon, bad_genomes_mutation_prob, activation_mutate_prob,
376
+ activation_mutate_add_prob, activation_mutate_delete_prob,
377
+ activation_mutate_change_prob, weight_mutate_prob, weight_mutate_threshold,
378
+ activation_mutate_threshold):
379
+ if policy == 'aggressive':
380
+ first_parent_W = best_weight
381
+ first_parent_act = best_activations
382
+ elif policy == 'explorer':
383
+ first_parent_W = good_weights[i]
384
+ first_parent_act = good_activations[i]
385
+ else:
386
+ raise ValueError("policy parameter must be: 'aggressive' or 'explorer'")
387
+
388
+ second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
389
+ child_W[i], child_act[i] = cross_over(first_parent_W,
390
+ second_parent_W,
391
+ first_parent_act,
392
+ second_parent_act,
393
+ cross_over_mode=cross_over_mode,
394
+ activation_selection_add_prob=activation_selection_add_prob,
395
+ activation_selection_change_prob=activation_selection_change_prob,
396
+ activation_selection_threshold=activation_selection_threshold,
397
+ bad_genomes_selection_prob=bad_genomes_selection_prob,
398
+ first_parent_fitness=best_fitness,
399
+ fitness_bias=fitness_bias,
400
+ second_parent_fitness=normalized_fitness[s_i],
401
+ epsilon=epsilon
402
+ )
403
+
401
404
  def evaluate(x_population, weights, activation_potentiations):
402
405
  """
403
406
  Evaluates the performance of a population of genomes, applying different activation functions