pyerualjetwork 4.6.3__py3-none-any.whl → 4.6.4__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.3"
1
+ __version__ = "4.6.4"
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
@@ -428,33 +428,4 @@ def batcher(x_test, y_test, batch_size=1):
428
428
  sampled_x.append(x_test[sampled_indices])
429
429
  sampled_y.append(y_test[sampled_indices])
430
430
 
431
- return np.concatenate(sampled_x), np.concatenate(sampled_y)
432
-
433
- def split_nested_arrays(data, dtype):
434
-
435
- n_samples = len(data)
436
- if n_samples == 0:
437
- return []
438
-
439
- n_components = len(data[0])
440
-
441
- result = []
442
-
443
- for i in range(n_components):
444
- component_array = np.array([item[i] for item in data], dtype=dtype)
445
- result.append(component_array)
446
-
447
- return result
448
-
449
-
450
- def reconstruct_nested_arrays(component_arrays):
451
-
452
- n_components = len(component_arrays)
453
- n_samples = len(component_arrays[0])
454
-
455
- reconstructed_data = []
456
- for i in range(n_samples):
457
- sample = [component_arrays[j][i] for j in range(n_components)]
458
- reconstructed_data.append(sample)
459
-
460
- return reconstructed_data
431
+ return np.concatenate(sampled_x), np.concatenate(sampled_y)
@@ -476,34 +476,4 @@ def batcher(x_test, y_test, batch_size=1):
476
476
 
477
477
  offset += num_samples
478
478
 
479
- return sampled_x, sampled_y
480
-
481
-
482
- def split_nested_arrays(data, dtype):
483
-
484
- n_samples = len(data)
485
- if n_samples == 0:
486
- return []
487
-
488
- n_components = len(data[0])
489
-
490
- result = []
491
-
492
- for i in range(n_components):
493
- component_array = cp.array([item[i] for item in data], dtype=dtype)
494
- result.append(component_array)
495
-
496
- return result
497
-
498
-
499
- def reconstruct_nested_arrays(component_arrays):
500
-
501
- n_components = len(component_arrays)
502
- n_samples = len(component_arrays[0])
503
-
504
- reconstructed_data = []
505
- for i in range(n_samples):
506
- sample = [component_arrays[j][i] for j in range(n_components)]
507
- reconstructed_data.append(sample)
508
-
509
- return reconstructed_data
479
+ return sampled_x, sampled_y
pyerualjetwork/planeat.py CHANGED
@@ -17,9 +17,9 @@ import random
17
17
  import math
18
18
 
19
19
  ### LIBRARY IMPORTS ###
20
- from .data_operations import normalization, non_neg_normalization, split_nested_arrays, reconstruct_nested_arrays
21
- from .ui import loading_bars, initialize_loading_bar
22
- from .activation_functions import apply_activation, all_activations
20
+ from data_operations import normalization, non_neg_normalization
21
+ from ui import loading_bars, initialize_loading_bar
22
+ from activation_functions import apply_activation, all_activations
23
23
 
24
24
  def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons=None, activation_functions=None, dtype=np.float32):
25
25
  """
@@ -56,7 +56,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
56
56
  and normalized using the `normalization()` function. (Max abs normalization.)
57
57
  """
58
58
  if hidden > 0:
59
- population_weights = [[0] * (hidden + 1) for _ in range(population_size)]
59
+ population_weights = np.empty((population_size, hidden + 1), dtype=object)
60
60
  population_activations = [[0] * (hidden) for _ in range(population_size)]
61
61
 
62
62
  if len(neurons) != hidden:
@@ -87,7 +87,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
87
87
  population_weights[i][l][j,:] = normalization(population_weights[i][l][j,:], dtype=dtype)
88
88
 
89
89
  return population_weights, population_activations
90
-
90
+
91
91
  else:
92
92
  population_weights = [0] * population_size
93
93
  population_activations = [0] * population_size
@@ -309,33 +309,10 @@ def evolver(weights,
309
309
 
310
310
  if weight_evolve is False: origin_weights = np.copy(weights)
311
311
 
312
- if is_mlp: ### IF EACH GENOME HAVE MORE THEN 1 WEIGHT MATRIX IT IS NOT PLAN MODEL. IT IS MLP MODEL.
313
-
314
- activations = activation_potentiations.copy()
315
-
316
- return mlp_evolver(weights,
317
- activations,
318
- what_gen,
319
- dtype,
320
- fitness,
321
- policy,
322
- bad_genomes_selection_prob,
323
- bar_status,
324
- strategy,
325
- bad_genomes_mutation_prob,
326
- fitness_bias,
327
- cross_over_mode,
328
- activation_mutate_change_prob,
329
- activation_selection_change_prob,
330
- activation_selection_threshold,
331
- activation_mutate_prob,
332
- activation_mutate_threshold,
333
- weight_mutate_threshold,
334
- show_info,
335
- weight_mutate_prob,
336
- )
337
-
338
- if isinstance(weights, list): weights = np.array(weights, dtype=dtype)
312
+ if is_mlp:
313
+ activation_mutate_add_prob = 0
314
+ activation_selection_add_prob = 0
315
+ activation_mutate_delete_prob = 0
339
316
 
340
317
  ### FITNESS IS SORTED IN ASCENDING ORDER, AND THE WEIGHT AND ACTIVATIONS OF EACH GENOME ARE SORTED ACCORDING TO THIS ORDER:
341
318
 
@@ -366,7 +343,7 @@ def evolver(weights,
366
343
 
367
344
  best_fitness = normalized_fitness[-1]
368
345
  epsilon = np.finfo(float).eps
369
-
346
+
370
347
  child_W = np.copy(bad_weights)
371
348
  child_act = bad_activations.copy()
372
349
 
@@ -379,38 +356,63 @@ def evolver(weights,
379
356
  if policy == 'aggressive':
380
357
  first_parent_W = best_weight
381
358
  first_parent_act = best_activations
359
+ first_parent_fitness = best_fitness
382
360
 
383
361
  elif policy == 'explorer':
384
362
  first_parent_W = good_weights[i]
385
363
  first_parent_act = good_activations[i]
364
+ first_parent_fitness = normalized_fitness[len(good_weights) + i]
386
365
 
387
366
  else: raise ValueError("policy parameter must be: 'aggressive' or 'explorer'")
388
367
 
389
368
  second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
390
369
 
391
- child_W[i], child_act[i] = cross_over(first_parent_W,
392
- second_parent_W,
393
- first_parent_act,
394
- second_parent_act,
395
- cross_over_mode=cross_over_mode,
396
- activation_selection_add_prob=activation_selection_add_prob,
397
- activation_selection_change_prob=activation_selection_change_prob,
398
- activation_selection_threshold=activation_selection_threshold,
399
- bad_genomes_selection_prob=bad_genomes_selection_prob,
400
- first_parent_fitness=best_fitness,
401
- fitness_bias=fitness_bias,
402
- second_parent_fitness=normalized_fitness[s_i],
403
- weight_evolve=weight_evolve,
404
- epsilon=epsilon
405
- )
370
+ if is_mlp:
371
+ for l in range(len(first_parent_W)):
372
+
373
+ if l == 0:
374
+ act_l = 0
375
+ else:
376
+ act_l = l - 1
406
377
 
378
+ child_W[i][l], child_act[i][act_l] = cross_over(first_parent_W[l],
379
+ second_parent_W[l],
380
+ first_parent_act[act_l],
381
+ second_parent_act[act_l],
382
+ cross_over_mode=cross_over_mode,
383
+ activation_selection_add_prob=activation_selection_add_prob,
384
+ activation_selection_change_prob=activation_selection_change_prob,
385
+ activation_selection_threshold=activation_selection_threshold,
386
+ bad_genomes_selection_prob=bad_genomes_selection_prob,
387
+ first_parent_fitness=first_parent_fitness,
388
+ fitness_bias=fitness_bias,
389
+ second_parent_fitness=normalized_fitness[s_i],
390
+ weight_evolve=weight_evolve,
391
+ epsilon=epsilon
392
+ )
393
+ else:
394
+ child_W[i], child_act[i] = cross_over(first_parent_W,
395
+ second_parent_W,
396
+ first_parent_act,
397
+ second_parent_act,
398
+ cross_over_mode=cross_over_mode,
399
+ activation_selection_add_prob=activation_selection_add_prob,
400
+ activation_selection_change_prob=activation_selection_change_prob,
401
+ activation_selection_threshold=activation_selection_threshold,
402
+ bad_genomes_selection_prob=bad_genomes_selection_prob,
403
+ first_parent_fitness=first_parent_fitness,
404
+ fitness_bias=fitness_bias,
405
+ second_parent_fitness=normalized_fitness[s_i],
406
+ weight_evolve=weight_evolve,
407
+ epsilon=epsilon
408
+ )
407
409
  mutation_prob = random.uniform(0, 1)
408
410
 
409
411
  if mutation_prob > bad_genomes_mutation_prob:
410
412
  genome_W = good_weights[i]
411
413
  genome_act = good_activations[i]
412
414
 
413
- fitness_index = int(len(bad_weights) / 2 + i)
415
+ fitness_index = int(len(good_weights) + i)
414
416
 
415
417
  else:
416
418
  genome_W = bad_weights[i]
@@ -418,28 +420,55 @@ def evolver(weights,
418
420
 
419
421
  fitness_index = i
420
422
 
421
- mutated_W[i], mutated_act[i] = mutation(genome_W,
422
- genome_act,
423
- activation_mutate_prob=activation_mutate_prob,
424
- activation_add_prob=activation_mutate_add_prob,
425
- activation_delete_prob=activation_mutate_delete_prob,
426
- activation_change_prob=activation_mutate_change_prob,
427
- weight_mutate_prob=weight_mutate_prob,
428
- weight_mutate_threshold=weight_mutate_threshold,
429
- genome_fitness=normalized_fitness[fitness_index],
430
- activation_mutate_threshold=activation_mutate_threshold,
431
- weight_evolve=weight_evolve,
432
- epsilon=epsilon
433
- )
423
+ if is_mlp:
424
+ for l in range(len(genome_W)):
434
425
 
435
- if bar_status: progress.update(1)
426
+ if l == 0:
427
+ act_l = 0
428
+ else:
429
+ act_l = l - 1
436
430
 
431
+ mutated_W[i][l], mutated_act[i][act_l] = mutation(genome_W[l],
432
+ genome_act[act_l],
433
+ activation_mutate_prob=activation_mutate_prob,
434
+ activation_add_prob=activation_mutate_add_prob,
435
+ activation_delete_prob=activation_mutate_delete_prob,
436
+ activation_change_prob=activation_mutate_change_prob,
437
+ weight_mutate_prob=weight_mutate_prob,
438
+ weight_mutate_threshold=weight_mutate_threshold,
439
+ genome_fitness=normalized_fitness[fitness_index],
440
+ activation_mutate_threshold=activation_mutate_threshold,
441
+ weight_evolve=weight_evolve,
442
+ epsilon=epsilon
443
+ )
444
+ else:
445
+ mutated_W[i], mutated_act[i] = mutation(genome_W,
446
+ genome_act,
447
+ activation_mutate_prob=activation_mutate_prob,
448
+ activation_add_prob=activation_mutate_add_prob,
449
+ activation_delete_prob=activation_mutate_delete_prob,
450
+ activation_change_prob=activation_mutate_change_prob,
451
+ weight_mutate_prob=weight_mutate_prob,
452
+ weight_mutate_threshold=weight_mutate_threshold,
453
+ genome_fitness=normalized_fitness[fitness_index],
454
+ activation_mutate_threshold=activation_mutate_threshold,
455
+ weight_evolve=weight_evolve,
456
+ epsilon=epsilon
457
+ )
458
+
459
+ if bar_status: progress.update(1)
460
+
437
461
  child_W[0] = best_weight
438
462
  child_act[0] = best_activations
439
463
 
440
- weights = np.vstack((child_W, mutated_W), dtype=dtype)
464
+ if is_mlp:
465
+ weights = np.vstack((child_W, mutated_W), dtype=object)
466
+ else:
467
+ weights = np.vstack((child_W, mutated_W), dtype=dtype)
468
+
441
469
  activation_potentiations = child_act + mutated_act
442
470
 
471
+
443
472
  ### INFO PRINTING CONSOLE
444
473
 
445
474
  if show_info == True:
@@ -529,65 +558,6 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
529
558
 
530
559
  return result
531
560
 
532
- def mlp_evolver(weights,
533
- activations,
534
- generation,
535
- dtype,
536
- fitness,
537
- policy,
538
- bad_genomes_selection_prob,
539
- bar_status,
540
- strategy,
541
- bad_genomes_mutation_prob,
542
- fitness_bias,
543
- cross_over_mode,
544
- activation_mutate_change_prob,
545
- activation_selection_change_prob,
546
- activation_selection_threshold,
547
- activation_mutate_prob,
548
- activation_mutate_threshold,
549
- weight_mutate_threshold,
550
- show_info,
551
- weight_mutate_prob,
552
- ):
553
-
554
- weights = split_nested_arrays(weights, dtype)
555
-
556
- for layer in range(len(weights)):
557
- if show_info == True:
558
- if layer == len(weights) - 1:
559
- show = True
560
- else:
561
- show = False
562
- else:
563
- show = False
564
-
565
- weights[layer], activations = evolver(weights[layer], activations,
566
- fitness=fitness,
567
- what_gen=generation,
568
- show_info=show,
569
- policy=policy,
570
- bad_genomes_selection_prob=bad_genomes_selection_prob,
571
- bar_status=bar_status,
572
- strategy=strategy,
573
- bad_genomes_mutation_prob=bad_genomes_mutation_prob,
574
- fitness_bias=fitness_bias,
575
- cross_over_mode=cross_over_mode,
576
- activation_mutate_add_prob=0,
577
- activation_mutate_delete_prob=0,
578
- activation_mutate_change_prob=activation_mutate_change_prob,
579
- activation_selection_add_prob=0,
580
- activation_selection_change_prob=activation_selection_change_prob,
581
- activation_selection_threshold=activation_selection_threshold,
582
- activation_mutate_prob=activation_mutate_prob,
583
- activation_mutate_threshold=activation_mutate_threshold,
584
- weight_mutate_threshold=weight_mutate_threshold,
585
- weight_mutate_prob=weight_mutate_prob,
586
- dtype=dtype
587
- )
588
-
589
- return reconstruct_nested_arrays(weights), activations
590
-
591
561
  def cross_over(first_parent_W,
592
562
  second_parent_W,
593
563
  first_parent_act,
@@ -19,9 +19,9 @@ import math
19
19
 
20
20
 
21
21
  ### LIBRARY IMPORTS ###
22
- from .data_operations_cuda import normalization, non_neg_normalization, split_nested_arrays, reconstruct_nested_arrays
23
- from .ui import loading_bars, initialize_loading_bar
24
- from .activation_functions_cuda import apply_activation, all_activations
22
+ from data_operations_cuda import normalization, non_neg_normalization
23
+ from ui import loading_bars, initialize_loading_bar
24
+ from activation_functions_cuda import apply_activation, all_activations
25
25
 
26
26
  def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons=None, activation_functions=None, dtype=cp.float32):
27
27
  """
@@ -47,7 +47,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
47
47
 
48
48
  Returns:
49
49
  tuple: A tuple containing:
50
- - population_weights (numpy.ndarray): A 2D numpy array of shape (population_size, output_shape, input_shape) representing the
50
+ - population_weights (cupy.ndarray): A 2D numpy array of shape (population_size, output_shape, input_shape) representing the
51
51
  weight matrices for each genome.
52
52
  - population_activations (list): A list of activation functions applied to each genome.
53
53
 
@@ -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 = [[0] * (hidden + 1) for _ in range(population_size)]
61
+ population_weights = cp.empty((population_size, hidden + 1), dtype=object)
62
62
  population_activations = [[0] * (hidden) for _ in range(population_size)]
63
63
 
64
64
  if len(neurons) != hidden:
@@ -88,8 +88,6 @@ 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
-
93
91
  else:
94
92
  population_weights = [0] * population_size
95
93
  population_activations = [0] * population_size
@@ -109,7 +107,7 @@ def define_genomes(input_shape, output_shape, population_size, hidden=0, neurons
109
107
  population_weights[i][j,:] = apply_activation(population_weights[i][j,:], population_activations[i])
110
108
  population_weights[i][j,:] = normalization(population_weights[i][j,:], dtype=dtype)
111
109
 
112
- return cp.array(population_weights, dtype=dtype), population_activations
110
+ return population_weights, population_activations
113
111
 
114
112
 
115
113
  def evolver(weights,
@@ -310,33 +308,10 @@ def evolver(weights,
310
308
 
311
309
  if weight_evolve is False: origin_weights = cp.copy(weights)
312
310
 
313
- if is_mlp: ### IF EACH GENOME HAVE MORE THEN 1 WEIGHT MATRIX IT IS NOT PLAN MODEL. IT IS MLP MODEL.
314
-
315
- activations = activation_potentiations.copy()
316
-
317
- return mlp_evolver(weights,
318
- activations,
319
- what_gen,
320
- dtype,
321
- fitness,
322
- policy,
323
- bad_genomes_selection_prob,
324
- bar_status,
325
- strategy,
326
- bad_genomes_mutation_prob,
327
- fitness_bias,
328
- cross_over_mode,
329
- activation_mutate_change_prob,
330
- activation_selection_change_prob,
331
- activation_selection_threshold,
332
- activation_mutate_prob,
333
- activation_mutate_threshold,
334
- weight_mutate_threshold,
335
- show_info,
336
- weight_mutate_prob,
337
- )
338
-
339
- if isinstance(weights, list): weights = cp.array(weights, dtype=dtype)
311
+ if is_mlp:
312
+ activation_mutate_add_prob = 0
313
+ activation_selection_add_prob = 0
314
+ activation_mutate_delete_prob = 0
340
315
 
341
316
  ### FITNESS LIST IS SORTED IN ASCENDING ORDER, AND THE WEIGHT AND ACTIVATIONS OF EACH GENOME ARE SORTED ACCORDING TO THIS ORDER:
342
317
 
@@ -380,30 +355,56 @@ def evolver(weights,
380
355
  if policy == 'aggressive':
381
356
  first_parent_W = best_weight
382
357
  first_parent_act = best_activations
358
+ first_parent_fitness = best_fitness
383
359
 
384
360
  elif policy == 'explorer':
385
361
  first_parent_W = good_weights[i]
386
362
  first_parent_act = good_activations[i]
363
+ first_parent_fitness = normalized_fitness[len(good_weights) + i]
387
364
 
388
365
  else: raise ValueError("policy parameter must be: 'aggressive' or 'explorer'")
389
366
 
390
367
  second_parent_W, second_parent_act, s_i = second_parent_selection(good_weights, bad_weights, good_activations, bad_activations, bad_genomes_selection_prob)
391
368
 
392
- child_W[i], child_act[i] = cross_over(first_parent_W,
393
- second_parent_W,
394
- first_parent_act,
395
- second_parent_act,
396
- cross_over_mode=cross_over_mode,
397
- activation_selection_add_prob=activation_selection_add_prob,
398
- activation_selection_change_prob=activation_selection_change_prob,
399
- activation_selection_threshold=activation_selection_threshold,
400
- bad_genomes_selection_prob=bad_genomes_selection_prob,
401
- first_parent_fitness=best_fitness,
402
- fitness_bias=fitness_bias,
403
- second_parent_fitness=normalized_fitness[s_i],
404
- weight_evolve=weight_evolve,
405
- epsilon=epsilon
406
- )
369
+ if is_mlp:
370
+ for l in range(len(first_parent_W)):
371
+
372
+ if l == 0:
373
+ act_l = 0
374
+ else:
375
+ act_l = l - 1
376
+
377
+ child_W[i][l], child_act[i][act_l] = cross_over(first_parent_W[l],
378
+ second_parent_W[l],
379
+ first_parent_act[act_l],
380
+ second_parent_act[act_l],
381
+ cross_over_mode=cross_over_mode,
382
+ activation_selection_add_prob=activation_selection_add_prob,
383
+ activation_selection_change_prob=activation_selection_change_prob,
384
+ activation_selection_threshold=activation_selection_threshold,
385
+ bad_genomes_selection_prob=bad_genomes_selection_prob,
386
+ first_parent_fitness=first_parent_fitness,
387
+ fitness_bias=fitness_bias,
388
+ second_parent_fitness=normalized_fitness[s_i],
389
+ weight_evolve=weight_evolve,
390
+ epsilon=epsilon
391
+ )
392
+ else:
393
+ child_W[i], child_act[i] = cross_over(first_parent_W,
394
+ second_parent_W,
395
+ first_parent_act,
396
+ second_parent_act,
397
+ cross_over_mode=cross_over_mode,
398
+ activation_selection_add_prob=activation_selection_add_prob,
399
+ activation_selection_change_prob=activation_selection_change_prob,
400
+ activation_selection_threshold=activation_selection_threshold,
401
+ bad_genomes_selection_prob=bad_genomes_selection_prob,
402
+ first_parent_fitness=first_parent_fitness,
403
+ fitness_bias=fitness_bias,
404
+ second_parent_fitness=normalized_fitness[s_i],
405
+ weight_evolve=weight_evolve,
406
+ epsilon=epsilon
407
+ )
407
408
 
408
409
  mutation_prob = random.uniform(0, 1)
409
410
 
@@ -411,7 +412,7 @@ def evolver(weights,
411
412
  genome_W = good_weights[i]
412
413
  genome_act = good_activations[i]
413
414
 
414
- fitness_index = int(len(bad_weights) / 2 + i)
415
+ fitness_index = int(len(good_weights) + i)
415
416
 
416
417
  else:
417
418
  genome_W = bad_weights[i]
@@ -419,26 +420,52 @@ def evolver(weights,
419
420
 
420
421
  fitness_index = i
421
422
 
422
- mutated_W[i], mutated_act[i] = mutation(genome_W,
423
- genome_act,
424
- activation_mutate_prob=activation_mutate_prob,
425
- activation_add_prob=activation_mutate_add_prob,
426
- activation_delete_prob=activation_mutate_delete_prob,
427
- activation_change_prob=activation_mutate_change_prob,
428
- weight_mutate_prob=weight_mutate_prob,
429
- weight_mutate_threshold=weight_mutate_threshold,
430
- genome_fitness=normalized_fitness[fitness_index],
431
- activation_mutate_threshold=activation_mutate_threshold,
432
- weight_evolve=weight_evolve,
433
- epsilon=epsilon
434
- )
423
+ if is_mlp:
424
+ for l in range(len(genome_W)):
425
+
426
+ if l == 0:
427
+ act_l = 0
428
+ else:
429
+ act_l = l - 1
430
+
431
+ mutated_W[i][l], mutated_act[i][act_l] = mutation(genome_W[l],
432
+ genome_act[act_l],
433
+ activation_mutate_prob=activation_mutate_prob,
434
+ activation_add_prob=activation_mutate_add_prob,
435
+ activation_delete_prob=activation_mutate_delete_prob,
436
+ activation_change_prob=activation_mutate_change_prob,
437
+ weight_mutate_prob=weight_mutate_prob,
438
+ weight_mutate_threshold=weight_mutate_threshold,
439
+ genome_fitness=normalized_fitness[fitness_index],
440
+ activation_mutate_threshold=activation_mutate_threshold,
441
+ weight_evolve=weight_evolve,
442
+ epsilon=epsilon
443
+ )
444
+ else:
445
+ mutated_W[i], mutated_act[i] = mutation(genome_W,
446
+ genome_act,
447
+ activation_mutate_prob=activation_mutate_prob,
448
+ activation_add_prob=activation_mutate_add_prob,
449
+ activation_delete_prob=activation_mutate_delete_prob,
450
+ activation_change_prob=activation_mutate_change_prob,
451
+ weight_mutate_prob=weight_mutate_prob,
452
+ weight_mutate_threshold=weight_mutate_threshold,
453
+ genome_fitness=normalized_fitness[fitness_index],
454
+ activation_mutate_threshold=activation_mutate_threshold,
455
+ weight_evolve=weight_evolve,
456
+ epsilon=epsilon
457
+ )
435
458
 
436
459
  if bar_status: progress.update(1)
437
460
 
438
461
  child_W[0] = best_weight
439
462
  child_act[0] = best_activations
440
463
 
441
- weights = cp.vstack((child_W, mutated_W), dtype=dtype)
464
+ if is_mlp:
465
+ weights = cp.vstack((child_W, mutated_W), dtype=object)
466
+ else:
467
+ weights = cp.vstack((child_W, mutated_W), dtype=dtype)
468
+
442
469
  activation_potentiations = child_act + mutated_act
443
470
 
444
471
  ### INFO PRINTING CONSOLE
@@ -519,7 +546,7 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
519
546
 
520
547
  layer = Input
521
548
  for i in range(len(weights)):
522
- if i != len(weights) - 1 and i != 0: layer = apply_activation(layer, activation_potentiations[i])
549
+ if i != len(weights) - 1: layer = apply_activation(layer, activation_potentiations[i])
523
550
  layer = layer @ weights[i].T
524
551
 
525
552
  return layer
@@ -531,65 +558,6 @@ def evaluate(Input, weights, activation_potentiations, is_mlp=False):
531
558
 
532
559
  return result
533
560
 
534
- def mlp_evolver(weights,
535
- activations,
536
- generation,
537
- dtype,
538
- fitness,
539
- policy,
540
- bad_genomes_selection_prob,
541
- bar_status,
542
- strategy,
543
- bad_genomes_mutation_prob,
544
- fitness_bias,
545
- cross_over_mode,
546
- activation_mutate_change_prob,
547
- activation_selection_change_prob,
548
- activation_selection_threshold,
549
- activation_mutate_prob,
550
- activation_mutate_threshold,
551
- weight_mutate_threshold,
552
- show_info,
553
- weight_mutate_prob,
554
- ):
555
-
556
- weights = split_nested_arrays(weights, dtype)
557
-
558
- for layer in range(len(weights)):
559
- if show_info == True:
560
- if layer == len(weights) - 1:
561
- show = True
562
- else:
563
- show = False
564
- else:
565
- show = False
566
-
567
- weights[layer], activations = evolver(weights[layer], activations,
568
- fitness=fitness,
569
- what_gen=generation,
570
- show_info=show,
571
- policy=policy,
572
- bad_genomes_selection_prob=bad_genomes_selection_prob,
573
- bar_status=bar_status,
574
- strategy=strategy,
575
- bad_genomes_mutation_prob=bad_genomes_mutation_prob,
576
- fitness_bias=fitness_bias,
577
- cross_over_mode=cross_over_mode,
578
- activation_mutate_add_prob=0,
579
- activation_mutate_delete_prob=0,
580
- activation_mutate_change_prob=activation_mutate_change_prob,
581
- activation_selection_add_prob=0,
582
- activation_selection_change_prob=activation_selection_change_prob,
583
- activation_selection_threshold=activation_selection_threshold,
584
- activation_mutate_prob=activation_mutate_prob,
585
- activation_mutate_threshold=activation_mutate_threshold,
586
- weight_mutate_threshold=weight_mutate_threshold,
587
- weight_mutate_prob=weight_mutate_prob,
588
- dtype=dtype
589
- )
590
-
591
- return reconstruct_nested_arrays(weights), activations
592
-
593
561
  def cross_over(first_parent_W,
594
562
  second_parent_W,
595
563
  first_parent_act,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.6.3
3
+ Version: 4.6.4
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=VwT_tzGQ_j-4Ou_OSz3X2NqF9XQ3NkhjYzUFo6K_WeI,1279
1
+ pyerualjetwork/__init__.py,sha256=YUTYZKlP8YA8lCrb_TkI86g7do3X5ju4SpOohnsqEBg,1279
2
2
  pyerualjetwork/activation_functions.py,sha256=Ms0AGBqkJuCA42ht64MSQnO54Td_1eDGquedpoBDVbc,7642
3
3
  pyerualjetwork/activation_functions_cuda.py,sha256=5y1Ti3GDfDteQDCUmODwe7tAyDAUlDTKmIikChQ8d6g,7772
4
- pyerualjetwork/data_operations.py,sha256=_7rS4Addogv25mpMUf0mjBDqTYFzrBp4rGA1ji08VkI,16001
5
- pyerualjetwork/data_operations_cuda.py,sha256=0TaTjrG85rdqQjM4IfQbrXqle4Wc-nkykPtd_aM0ItA,18104
4
+ pyerualjetwork/data_operations.py,sha256=Y_RdxkjLEszFgeo4VDWIX1keF2syP-88KesLXA5sRyY,15280
5
+ pyerualjetwork/data_operations_cuda.py,sha256=9tyD3Bbv5__stuUampgh3_GbMhb_kmTTJmZi7BJsvuA,17381
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
@@ -14,12 +14,12 @@ pyerualjetwork/model_operations.py,sha256=fr64XCwgl1YRh5nP3sEkvQORKHb-2lF_a4Kjcl
14
14
  pyerualjetwork/model_operations_cuda.py,sha256=-Kv8fYqHSU0L9FalOsQ7EWCwCEwjgUySObyueOqCH_o,16134
15
15
  pyerualjetwork/plan.py,sha256=UyIvPmvHCHwczlc9KHolE4y6CPEeBfhnRN5yznSbnoM,23028
16
16
  pyerualjetwork/plan_cuda.py,sha256=iteqgv7x9Z2Pj4vGOZs6HXS3r0bNaF_smr7ZXaOdRnw,23990
17
- pyerualjetwork/planeat.py,sha256=KgI1RCNvYxGfw2wQ7dWFLLZrPE6ys9agS4bjodq2W9U,45312
18
- pyerualjetwork/planeat_cuda.py,sha256=K0YWrH2POXsD9xiUq9zqPulan57uspeIa16XjknsNwk,45357
17
+ pyerualjetwork/planeat.py,sha256=JTS8a3SCqqh-Ct5XIQ02FcHGqShdBTAtY2d_C7nyawI,44640
18
+ pyerualjetwork/planeat_cuda.py,sha256=0xLYM3YmMCB61G8nKOVq5DcvZPiBzkzqhW4fPjVWL3g,44645
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.3.dist-info/METADATA,sha256=b6-XwpCnTnMIO5YVBJ3wA378PWyD9zde598dI_1_Gqg,7505
23
- pyerualjetwork-4.6.3.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
- pyerualjetwork-4.6.3.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
25
- pyerualjetwork-4.6.3.dist-info/RECORD,,
22
+ pyerualjetwork-4.6.4.dist-info/METADATA,sha256=b0nf9JEqKAAoWbRHTuVRm-rHEmG2XklkOI3cdqATpxc,7505
23
+ pyerualjetwork-4.6.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
+ pyerualjetwork-4.6.4.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
25
+ pyerualjetwork-4.6.4.dist-info/RECORD,,