pyerualjetwork 2.0.3__py3-none-any.whl → 2.0.5__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 +40 -35
- {pyerualjetwork-2.0.3.dist-info → pyerualjetwork-2.0.5.dist-info}/METADATA +2 -2
- pyerualjetwork-2.0.5.dist-info/RECORD +6 -0
- pyerualjetwork-2.0.3.dist-info/RECORD +0 -6
- {pyerualjetwork-2.0.3.dist-info → pyerualjetwork-2.0.5.dist-info}/WHEEL +0 -0
- {pyerualjetwork-2.0.3.dist-info → pyerualjetwork-2.0.5.dist-info}/top_level.txt +0 -0
plan/plan.py
CHANGED
@@ -16,7 +16,7 @@ import seaborn as sns
|
|
16
16
|
def fit(
|
17
17
|
x_train: List[Union[int, float]],
|
18
18
|
y_train: List[Union[int, float, str]], # At least two.. and one hot encoded
|
19
|
-
|
19
|
+
activation_potential: Union[float],
|
20
20
|
) -> str:
|
21
21
|
|
22
22
|
infoPLAN = """
|
@@ -25,13 +25,18 @@ def fit(
|
|
25
25
|
Args:
|
26
26
|
x_train (list[num]): List of input data.
|
27
27
|
y_train (list[num]): List of y_train. (one hot encoded)
|
28
|
-
|
28
|
+
activation_potential (float): Input activation potential
|
29
29
|
|
30
30
|
Returns:
|
31
|
-
list([num]): (Weight matrices list, train_predictions list,
|
31
|
+
list([num]): (Weight matrices list, train_predictions list, Train_acc).
|
32
32
|
error handled ?: Process status ('e')
|
33
33
|
"""
|
34
34
|
|
35
|
+
if activation_potential < 0 or activation_potential > 1:
|
36
|
+
|
37
|
+
print(Fore.RED + "ERROR101: ACTIVATION potential value must be in range 0-1. from: fit",infoPLAN)
|
38
|
+
return 'e'
|
39
|
+
|
35
40
|
if len(x_train) != len(y_train):
|
36
41
|
print(Fore.RED + "ERROR301: x_train list and y_train list must be same length. from: fit",infoPLAN)
|
37
42
|
return 'e'
|
@@ -92,9 +97,9 @@ def fit(
|
|
92
97
|
|
93
98
|
|
94
99
|
if Layer == 'fex':
|
95
|
-
neural_layer,W[Lindex] = fex(neural_layer, W[Lindex],
|
100
|
+
neural_layer,W[Lindex] = fex(neural_layer, W[Lindex], activation_potential, Piece[Windex], 1)
|
96
101
|
elif Layer == 'cat':
|
97
|
-
neural_layer,W[Lindex] = cat(neural_layer, W[Lindex],
|
102
|
+
neural_layer,W[Lindex] = cat(neural_layer, W[Lindex], activation_potential, 1, Piece[Windex])
|
98
103
|
|
99
104
|
RealOutput = np.argmax(y_train[index])
|
100
105
|
PredictedOutput = np.argmax(neural_layer)
|
@@ -314,25 +319,25 @@ def synaptic_dividing(
|
|
314
319
|
def fex(
|
315
320
|
Input, # list[num]: Input data.
|
316
321
|
w, # list[list[num]]: Weight matrix of the neural network.,
|
317
|
-
|
322
|
+
activation_potential, # num: Threshold value for comparison.
|
318
323
|
piece, # ???
|
319
324
|
is_training # num: 1 or 0
|
320
325
|
) -> tuple:
|
321
326
|
"""
|
322
|
-
Applies feature
|
327
|
+
Applies feature extrACTIVATION process to the input data using synaptic pruning.
|
323
328
|
|
324
329
|
Args:
|
325
330
|
Input (list[num]): Input data.
|
326
331
|
w (list[list[num]]): Weight matrix of the neural network.
|
327
|
-
|
328
|
-
|
332
|
+
ACTIVATION_threshold (str): Sign for threshold comparison ('<', '>', '==', '!=').
|
333
|
+
activation_potential (num): Threshold value for comparison.
|
329
334
|
|
330
335
|
Returns:
|
331
336
|
tuple: A tuple (vector) containing the neural layer result and the updated weight matrix.
|
332
337
|
"""
|
333
338
|
|
334
339
|
|
335
|
-
PruneIndex = np.where(Input <
|
340
|
+
PruneIndex = np.where(Input < activation_potential)
|
336
341
|
w = synaptic_pruning(w, PruneIndex, 'col', 0, 0, piece, is_training)
|
337
342
|
|
338
343
|
neural_layer = np.dot(w, Input)
|
@@ -342,7 +347,7 @@ def fex(
|
|
342
347
|
def cat(
|
343
348
|
Input, # list[num]: Input data.
|
344
349
|
w, # list[list[num]]: Weight matrix of the neural network.
|
345
|
-
|
350
|
+
activation_potential, # num: Threshold value for comparison.
|
346
351
|
isTrain,
|
347
352
|
piece # int: Flag indicating if the function is called during training (1 for training, 0 otherwise).
|
348
353
|
) -> tuple:
|
@@ -352,8 +357,8 @@ def cat(
|
|
352
357
|
Args:
|
353
358
|
Input (list[num]): Input data.
|
354
359
|
w (list[list[num]]): Weight matrix of the neural network.
|
355
|
-
|
356
|
-
|
360
|
+
ACTIVATION_threshold (str): Sign for threshold comparison ('<', '>', '==', '!=').
|
361
|
+
activation_potential (num): Threshold value for comparison.
|
357
362
|
isTrain (int): Flag indicating if the function is called during training (1 for training, 0 otherwise).
|
358
363
|
|
359
364
|
Returns:
|
@@ -448,7 +453,7 @@ def Relu(
|
|
448
453
|
def evaluate(
|
449
454
|
x_test, # list[list[num]]: Test input data.
|
450
455
|
y_test, # list[num]: Test labels.
|
451
|
-
|
456
|
+
activation_potential, # list[num]: List of ACTIVATION POTENTIALS for each layer.
|
452
457
|
visualize, # visualize Testing procces or not visualize ('y' or 'n')
|
453
458
|
W # list[list[num]]: Weight matrix of the neural network.
|
454
459
|
) -> tuple:
|
@@ -458,7 +463,7 @@ def evaluate(
|
|
458
463
|
Args:
|
459
464
|
x_test (list[list[num]]): Test input data.
|
460
465
|
y_test (list[num]): Test labels.
|
461
|
-
|
466
|
+
activation_potential (float): Input activation potential
|
462
467
|
visualize (str): Visualize test progress ? ('y' or 'n')
|
463
468
|
W (list[list[num]]): Weight matrix of the neural network.
|
464
469
|
|
@@ -490,9 +495,9 @@ def evaluate(
|
|
490
495
|
neural_layer = normalization(neural_layer)
|
491
496
|
|
492
497
|
if layers[index] == 'fex':
|
493
|
-
neural_layer = fex(neural_layer, W[index],
|
498
|
+
neural_layer = fex(neural_layer, W[index], activation_potential, 0, 0)[0]
|
494
499
|
if layers[index] == 'cat':
|
495
|
-
neural_layer = cat(neural_layer, W[index],
|
500
|
+
neural_layer = cat(neural_layer, W[index], activation_potential, 0, 0)[0]
|
496
501
|
|
497
502
|
for i, w in enumerate(Wc):
|
498
503
|
W[i] = np.copy(w)
|
@@ -567,7 +572,7 @@ def evaluate(
|
|
567
572
|
|
568
573
|
except:
|
569
574
|
|
570
|
-
print(Fore.RED + "ERROR: Testing model parameters like '
|
575
|
+
print(Fore.RED + "ERROR: Testing model parameters like 'activation_potential' must be same as trained model. Check parameters. Are you sure weights are loaded ? from: evaluate" + infoTestModel + Style.RESET_ALL)
|
571
576
|
return 'e'
|
572
577
|
|
573
578
|
|
@@ -577,7 +582,7 @@ def evaluate(
|
|
577
582
|
def save_model(model_name,
|
578
583
|
model_type,
|
579
584
|
class_count,
|
580
|
-
|
585
|
+
activation_potential,
|
581
586
|
test_acc,
|
582
587
|
weights_type,
|
583
588
|
weights_format,
|
@@ -586,13 +591,13 @@ def save_model(model_name,
|
|
586
591
|
):
|
587
592
|
|
588
593
|
infosave_model = """
|
589
|
-
Function to save a
|
594
|
+
Function to save a pruning learning model.
|
590
595
|
|
591
596
|
Arguments:
|
592
597
|
model_name (str): Name of the model.
|
593
598
|
model_type (str): Type of the model.(options: PLAN)
|
594
599
|
class_count (int): Number of classes.
|
595
|
-
|
600
|
+
activation_potential (float): Activation potential.
|
596
601
|
test_acc (float): Test accuracy of the model.
|
597
602
|
weights_type (str): Type of weights to save (options: 'txt', 'npy', 'mat').
|
598
603
|
WeightFormat (str): Format of the weights (options: 'd', 'f', 'raw').
|
@@ -636,7 +641,7 @@ def save_model(model_name,
|
|
636
641
|
'LAYERS': layers,
|
637
642
|
'LAYER COUNT': len(layers),
|
638
643
|
'CLASS COUNT': class_count,
|
639
|
-
'
|
644
|
+
'ACTIVATION POTENTIAL': activation_potential,
|
640
645
|
'NEURON COUNT': NeuronCount,
|
641
646
|
'SYNAPSE COUNT': SynapseCount,
|
642
647
|
'TEST ACCURACY': test_acc,
|
@@ -733,7 +738,7 @@ def load_model(model_name,
|
|
733
738
|
model_path,
|
734
739
|
):
|
735
740
|
infoload_model = """
|
736
|
-
Function to load a
|
741
|
+
Function to load a pruning learning model.
|
737
742
|
|
738
743
|
Arguments:
|
739
744
|
model_name (str): Name of the model.
|
@@ -741,7 +746,7 @@ def load_model(model_name,
|
|
741
746
|
log_type (str): Type of log to load (options: 'csv', 'txt', 'hdf5').
|
742
747
|
|
743
748
|
Returns:
|
744
|
-
lists: W(list[num]),
|
749
|
+
lists: W(list[num]), activation_potential, df (DataFrame of the model)
|
745
750
|
"""
|
746
751
|
pass
|
747
752
|
|
@@ -761,7 +766,7 @@ def load_model(model_name,
|
|
761
766
|
layers = df['LAYERS'].tolist()
|
762
767
|
layer_count = int(df['LAYER COUNT'].iloc[0])
|
763
768
|
class_count = int(df['CLASS COUNT'].iloc[0])
|
764
|
-
|
769
|
+
activation_potential = int(df['ACTIVATION POTENTIAL'].iloc[0])
|
765
770
|
NeuronCount = int(df['NEURON COUNT'].iloc[0])
|
766
771
|
SynapseCount = int(df['SYNAPSE COUNT'].iloc[0])
|
767
772
|
test_acc = int(df['TEST ACCURACY'].iloc[0])
|
@@ -784,12 +789,12 @@ def load_model(model_name,
|
|
784
789
|
else:
|
785
790
|
raise ValueError(Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy' or 'mat' from: load_model." + infoload_model + Style.RESET_ALL)
|
786
791
|
print(Fore.GREEN + "Model loaded succesfully" + Style.RESET_ALL)
|
787
|
-
return W,
|
792
|
+
return W,activation_potential,df
|
788
793
|
|
789
794
|
def predict_model_ssd(Input,model_name,model_path):
|
790
795
|
|
791
796
|
infopredict_model_ssd = """
|
792
|
-
Function to make a prediction using a divided pruning
|
797
|
+
Function to make a prediction using a divided pruning learning artificial neural network (PLAN).
|
793
798
|
|
794
799
|
Arguments:
|
795
800
|
Input (list or ndarray): Input data for the model (single vector or single matrix).
|
@@ -798,7 +803,7 @@ def predict_model_ssd(Input,model_name,model_path):
|
|
798
803
|
Returns:
|
799
804
|
ndarray: Output from the model.
|
800
805
|
"""
|
801
|
-
W,
|
806
|
+
W,activation_potential = load_model(model_name,model_path)[0:2]
|
802
807
|
|
803
808
|
layers = ['fex','cat']
|
804
809
|
|
@@ -814,9 +819,9 @@ def predict_model_ssd(Input,model_name,model_path):
|
|
814
819
|
neural_layer = normalization(neural_layer)
|
815
820
|
|
816
821
|
if layers[index] == 'fex':
|
817
|
-
neural_layer = fex(neural_layer, W[index],
|
822
|
+
neural_layer = fex(neural_layer, W[index], activation_potential,0, 0)[0]
|
818
823
|
if layers[index] == 'cat':
|
819
|
-
neural_layer = cat(neural_layer, W[index],
|
824
|
+
neural_layer = cat(neural_layer, W[index], activation_potential, 0, 0)[0]
|
820
825
|
except:
|
821
826
|
print(Fore.RED + "ERROR: The input was probably entered incorrectly. from: predict_model_ssd" + infopredict_model_ssd + Style.RESET_ALL)
|
822
827
|
return 'e'
|
@@ -825,15 +830,15 @@ def predict_model_ssd(Input,model_name,model_path):
|
|
825
830
|
return neural_layer
|
826
831
|
|
827
832
|
|
828
|
-
def predict_model_ram(Input,
|
833
|
+
def predict_model_ram(Input,activation_potential,W):
|
829
834
|
|
830
835
|
infopredict_model_ram = """
|
831
|
-
Function to make a prediction using a pruning learning artificial neural network (PLAN)
|
836
|
+
Function to make a prediction using a divided pruning learning artificial neural network (PLAN).
|
832
837
|
from weights and parameters stored in memory.
|
833
838
|
|
834
839
|
Arguments:
|
835
840
|
Input (list or ndarray): Input data for the model (single vector or single matrix).
|
836
|
-
|
841
|
+
activation_potential (float): Activation potential.
|
837
842
|
W (list of ndarrays): Weights of the model.
|
838
843
|
|
839
844
|
Returns:
|
@@ -854,9 +859,9 @@ def predict_model_ram(Input,action_potential,W):
|
|
854
859
|
neural_layer = normalization(neural_layer)
|
855
860
|
|
856
861
|
if layers[index] == 'fex':
|
857
|
-
neural_layer = fex(neural_layer, W[index],
|
862
|
+
neural_layer = fex(neural_layer, W[index], activation_potential,0, 0)[0]
|
858
863
|
if layers[index] == 'cat':
|
859
|
-
neural_layer = cat(neural_layer, W[index],
|
864
|
+
neural_layer = cat(neural_layer, W[index], activation_potential, 0, 0)[0]
|
860
865
|
|
861
866
|
except:
|
862
867
|
print(Fore.RED + "ERROR: Unexpected input or wrong model parameters from: predict_model_ram." + infopredict_model_ram + Style.RESET_ALL)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyerualjetwork
|
3
|
-
Version: 2.0.
|
4
|
-
Summary: Advanced python deep learning library. New features: More simple and practical, all functions and variables are snake_case. (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)
|
3
|
+
Version: 2.0.5
|
4
|
+
Summary: Advanced python deep learning library. New features: More simple and practical, action_potential changed to activation_potential, all functions and variables are snake_case. (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)
|
5
5
|
Author: Hasan Can Beydili
|
6
6
|
Author-email: tchasancan@gmail.com
|
7
7
|
Keywords: model evaluation,classifcation,pruning learning artficial neural networks
|
@@ -0,0 +1,6 @@
|
|
1
|
+
plan/__init__.py,sha256=TYPKx35TBM7X814H-RQmVK9DduX5GX0JdTW7_-b2ZUc,377
|
2
|
+
plan/plan.py,sha256=VAQ9D8vIMJgyavkzWVPvH-coCp31x3YNP1iRrS9kHFs,33195
|
3
|
+
pyerualjetwork-2.0.5.dist-info/METADATA,sha256=q1uNR-YyoJmZaUmD9GotSajEkhL9z8Nl0R9B7r_nt6M,481
|
4
|
+
pyerualjetwork-2.0.5.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
5
|
+
pyerualjetwork-2.0.5.dist-info/top_level.txt,sha256=G0Al3HuNJ88434XneyDtRKAIUaLCizOFYFYNhd7e2OM,5
|
6
|
+
pyerualjetwork-2.0.5.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
plan/__init__.py,sha256=TYPKx35TBM7X814H-RQmVK9DduX5GX0JdTW7_-b2ZUc,377
|
2
|
-
plan/plan.py,sha256=E91r0m4lt6XqnFlrpDq_ijWSFX-yMqT9CeTtMuRUzoA,32839
|
3
|
-
pyerualjetwork-2.0.3.dist-info/METADATA,sha256=3WWM_e_w_6f7HsavoMHt1WzDP4W4x_Ak9ljawj1Mxcg,431
|
4
|
-
pyerualjetwork-2.0.3.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
5
|
-
pyerualjetwork-2.0.3.dist-info/top_level.txt,sha256=G0Al3HuNJ88434XneyDtRKAIUaLCizOFYFYNhd7e2OM,5
|
6
|
-
pyerualjetwork-2.0.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|