pyerualjetwork 2.7.2__py3-none-any.whl → 2.7.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.
plan/plan.py CHANGED
@@ -1,3 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Fri Jun 21 05:21:35 2024
4
+
5
+ @author: hasan
6
+ """
7
+
1
8
  # -*- coding: utf-8 -*-
2
9
  """
3
10
  Created on Tue Jun 18 23:32:16 2024
@@ -40,8 +47,8 @@ def fit(
40
47
  val (None, True or 'final'): validation in training process ? None, True or 'final' Default: None (optional)
41
48
  val_count (None, int): After how many examples learned will an accuracy test be performed? Default: 0.1 (%10) (optional)
42
49
  activation_potentiation (float): Input activation potentiation (for binary injection) (optional) in range: -1, 1
43
- x_val (list[num]): List of validation data. (optional) Default: 10% of x_train (auto_balanced)
44
- y_val (list[num]): (list[num]): List of target labels. (one hot encoded) (optional) Default: 10% of y_train (auto_balanced)
50
+ x_val (list[num]): List of validation data. (optional) Default: 1% of x_train (auto_balanced) it means every %1 of train progress starts validation
51
+ y_val (list[num]): (list[num]): List of target labels. (one hot encoded) (optional) Default: 1% of y_train (auto_balanced) it means every %1 of train progress starts validation
45
52
  show_training (bool, str): True, None or'final'
46
53
  show_count (None, int): How many learning steps in total will be displayed in a single figure? (Adjust according to your hardware) Default: 10 (optional)
47
54
  Returns:
@@ -72,7 +79,7 @@ def fit(
72
79
 
73
80
  if val_count == None:
74
81
 
75
- val_count = 0.1
82
+ val_count = 0.01
76
83
 
77
84
  v_iter = 0
78
85
 
@@ -246,7 +253,7 @@ def fit(
246
253
 
247
254
  if val == 'final':
248
255
 
249
- validation_model = evaluate(x_val, y_val, None, LTPW, activation_potentiation, None)
256
+ validation_model = evaluate(x_val, y_val, LTPW, activation_potentiation, bar_status=None, show_metrices=None)
250
257
 
251
258
  val_acc = validation_model[get_acc()]
252
259
 
@@ -469,7 +476,7 @@ def evaluate(
469
476
  y_test, # list[num]: Test labels.
470
477
  W, # list[num]: Weight matrix list of the neural network.
471
478
  activation_potentiation=None, # activation_potentiation (float or None): Threshold value for comparison. (optional) Default: None
472
- acc_bar_status=True, # acc_bar_status (bool): Loading bar for accuracy (True or None) (optional) Default: True
479
+ bar_status=True, # bar_status (bool): Loading bar for accuracy (True or None) (optional) Default: True
473
480
  show_metrices=None # show_metrices (bool): (True or None) (optional) Default: None
474
481
  ) -> tuple:
475
482
  infoTestModel = """
@@ -480,7 +487,7 @@ def evaluate(
480
487
  y_test (list[num]): Test labels.
481
488
  W (list[num]): Weight matrix list of the neural network.
482
489
  activation_potentiation (float or None): Threshold value for comparison. (optional) Default: None
483
- acc_bar_status (bool): Loading bar for accuracy (True or None) (optional) Default: True
490
+ bar_status (bool): Loading bar for accuracy (True or None) (optional) Default: True
484
491
  show_metrices (bool): (True or None) (optional) Default: None
485
492
 
486
493
  Returns:
@@ -489,69 +496,62 @@ def evaluate(
489
496
 
490
497
  layers = ['fex']
491
498
 
492
- try:
493
- Wc = [0] * len(W) # Wc = Weight copy
494
- true = 0
495
- y_preds = [-1] * len(y_test)
496
- acc_list = []
499
+ Wc = [0] * len(W) # Wc = Weight copy
500
+ true = 0
501
+ y_preds = [-1] * len(y_test)
502
+ acc_list = []
503
+
504
+ for i, w in enumerate(W):
505
+ Wc[i] = np.copy(w)
497
506
 
498
- for i, w in enumerate(W):
499
- Wc[i] = np.copy(w)
500
-
501
-
502
- if acc_bar_status == True:
503
-
504
- test_progress = tqdm(total=len(x_test),leave=False, desc='Testing',ncols=120)
505
- acc_bar = tqdm(total=1, desc="Test Accuracy", ncols=120)
506
-
507
507
 
508
- for inpIndex, Input in enumerate(x_test):
509
- Input = np.array(Input)
510
- Input = Input.ravel()
511
- neural_layer = Input
512
-
513
- for index, Layer in enumerate(layers):
514
-
515
- neural_layer = normalization(neural_layer)
508
+ if bar_status == True:
516
509
 
517
- if Layer == 'fex':
518
- neural_layer = fex(neural_layer, W[index], False, None, activation_potentiation)
510
+ test_progress = tqdm(total=len(x_test),leave=False, desc='Testing',ncols=120)
511
+ acc_bar = tqdm(total=1, desc="Test Accuracy", ncols=120)
512
+
513
+
514
+ for inpIndex, Input in enumerate(x_test):
515
+ Input = np.array(Input)
516
+ Input = Input.ravel()
517
+ neural_layer = Input
519
518
 
519
+ for index, Layer in enumerate(layers):
520
520
 
521
- for i, w in enumerate(Wc):
522
- W[i] = np.copy(w)
523
- RealOutput = np.argmax(y_test[inpIndex])
524
- PredictedOutput = np.argmax(neural_layer)
525
- if RealOutput == PredictedOutput:
526
- true += 1
527
- acc = true / len(y_test)
521
+ neural_layer = normalization(neural_layer)
528
522
 
523
+ if Layer == 'fex':
524
+ neural_layer = fex(neural_layer, W[index], False, None, activation_potentiation)
529
525
 
530
- acc_list.append(acc)
531
- y_preds[inpIndex] = PredictedOutput
532
-
533
- if acc_bar_status == True:
534
- test_progress.update(1)
535
- if inpIndex == 0:
536
- acc_bar.update(acc)
537
-
538
- else:
539
- acc = acc - acc_list[inpIndex - 1]
540
- acc_bar.update(acc)
541
526
 
542
- if show_metrices == True:
543
- plot_evaluate(y_test, y_preds, acc_list)
544
-
545
-
546
527
  for i, w in enumerate(Wc):
547
528
  W[i] = np.copy(w)
529
+ RealOutput = np.argmax(y_test[inpIndex])
530
+ PredictedOutput = np.argmax(neural_layer)
531
+ if RealOutput == PredictedOutput:
532
+ true += 1
533
+ acc = true / len(y_test)
548
534
 
549
- except:
550
535
 
551
- print(Fore.RED + "ERROR: Are you sure weights are loaded ? from: evaluate" +
552
- infoTestModel + Style.RESET_ALL)
553
- return 'e'
536
+ acc_list.append(acc)
537
+ y_preds[inpIndex] = PredictedOutput
538
+
539
+ if bar_status == True:
540
+ test_progress.update(1)
541
+ if inpIndex == 0:
542
+ acc_bar.update(acc)
543
+
544
+ else:
545
+ acc = acc - acc_list[inpIndex - 1]
546
+ acc_bar.update(acc)
547
+
548
+ if show_metrices == True:
549
+ plot_evaluate(y_test, y_preds, acc_list)
550
+
554
551
 
552
+ for i, w in enumerate(Wc):
553
+ W[i] = np.copy(w)
554
+
555
555
  return W, y_preds, acc
556
556
 
557
557
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 2.7.2
3
+ Version: 2.7.4
4
4
  Summary: Optimized for Vs Code
5
5
  Author: Hasan Can Beydili
6
6
  Author-email: tchasancan@gmail.com
@@ -0,0 +1,6 @@
1
+ plan/__init__.py,sha256=gmaz8lnQfl18MbOQwabBUPmShajK5S99jfyY-hQe8tc,502
2
+ plan/plan.py,sha256=t4Vghx1DcMYYzdzzdnd3G_fJobkJvNXVYMKAORJW8is,52772
3
+ pyerualjetwork-2.7.4.dist-info/METADATA,sha256=RJUQ5bKgoOSby1F9unDSKicejquxNMMZFRfdV1meZxY,248
4
+ pyerualjetwork-2.7.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
5
+ pyerualjetwork-2.7.4.dist-info/top_level.txt,sha256=G0Al3HuNJ88434XneyDtRKAIUaLCizOFYFYNhd7e2OM,5
6
+ pyerualjetwork-2.7.4.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- plan/__init__.py,sha256=gmaz8lnQfl18MbOQwabBUPmShajK5S99jfyY-hQe8tc,502
2
- plan/plan.py,sha256=C2gx96Y2eyve0_ACatu9T816vs4985gzSa-fxymevXo,52937
3
- pyerualjetwork-2.7.2.dist-info/METADATA,sha256=t8fcUy6KUZr5GkVZ7gWQDdGHAFUYjjLyKURgafIlDL4,248
4
- pyerualjetwork-2.7.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
5
- pyerualjetwork-2.7.2.dist-info/top_level.txt,sha256=G0Al3HuNJ88434XneyDtRKAIUaLCizOFYFYNhd7e2OM,5
6
- pyerualjetwork-2.7.2.dist-info/RECORD,,