pyerualjetwork 2.0.4__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 +37 -37
- {pyerualjetwork-2.0.4.dist-info → pyerualjetwork-2.0.5.dist-info}/METADATA +2 -2
- pyerualjetwork-2.0.5.dist-info/RECORD +6 -0
- pyerualjetwork-2.0.4.dist-info/RECORD +0 -6
- {pyerualjetwork-2.0.4.dist-info → pyerualjetwork-2.0.5.dist-info}/WHEEL +0 -0
- {pyerualjetwork-2.0.4.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,16 +25,16 @@ 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
|
35
|
+
if activation_potential < 0 or activation_potential > 1:
|
36
36
|
|
37
|
-
print(Fore.RED + "ERROR101:
|
37
|
+
print(Fore.RED + "ERROR101: ACTIVATION potential value must be in range 0-1. from: fit",infoPLAN)
|
38
38
|
return 'e'
|
39
39
|
|
40
40
|
if len(x_train) != len(y_train):
|
@@ -97,9 +97,9 @@ def fit(
|
|
97
97
|
|
98
98
|
|
99
99
|
if Layer == 'fex':
|
100
|
-
neural_layer,W[Lindex] = fex(neural_layer, W[Lindex],
|
100
|
+
neural_layer,W[Lindex] = fex(neural_layer, W[Lindex], activation_potential, Piece[Windex], 1)
|
101
101
|
elif Layer == 'cat':
|
102
|
-
neural_layer,W[Lindex] = cat(neural_layer, W[Lindex],
|
102
|
+
neural_layer,W[Lindex] = cat(neural_layer, W[Lindex], activation_potential, 1, Piece[Windex])
|
103
103
|
|
104
104
|
RealOutput = np.argmax(y_train[index])
|
105
105
|
PredictedOutput = np.argmax(neural_layer)
|
@@ -319,25 +319,25 @@ def synaptic_dividing(
|
|
319
319
|
def fex(
|
320
320
|
Input, # list[num]: Input data.
|
321
321
|
w, # list[list[num]]: Weight matrix of the neural network.,
|
322
|
-
|
322
|
+
activation_potential, # num: Threshold value for comparison.
|
323
323
|
piece, # ???
|
324
324
|
is_training # num: 1 or 0
|
325
325
|
) -> tuple:
|
326
326
|
"""
|
327
|
-
Applies feature
|
327
|
+
Applies feature extrACTIVATION process to the input data using synaptic pruning.
|
328
328
|
|
329
329
|
Args:
|
330
330
|
Input (list[num]): Input data.
|
331
331
|
w (list[list[num]]): Weight matrix of the neural network.
|
332
|
-
|
333
|
-
|
332
|
+
ACTIVATION_threshold (str): Sign for threshold comparison ('<', '>', '==', '!=').
|
333
|
+
activation_potential (num): Threshold value for comparison.
|
334
334
|
|
335
335
|
Returns:
|
336
336
|
tuple: A tuple (vector) containing the neural layer result and the updated weight matrix.
|
337
337
|
"""
|
338
338
|
|
339
339
|
|
340
|
-
PruneIndex = np.where(Input <
|
340
|
+
PruneIndex = np.where(Input < activation_potential)
|
341
341
|
w = synaptic_pruning(w, PruneIndex, 'col', 0, 0, piece, is_training)
|
342
342
|
|
343
343
|
neural_layer = np.dot(w, Input)
|
@@ -347,7 +347,7 @@ def fex(
|
|
347
347
|
def cat(
|
348
348
|
Input, # list[num]: Input data.
|
349
349
|
w, # list[list[num]]: Weight matrix of the neural network.
|
350
|
-
|
350
|
+
activation_potential, # num: Threshold value for comparison.
|
351
351
|
isTrain,
|
352
352
|
piece # int: Flag indicating if the function is called during training (1 for training, 0 otherwise).
|
353
353
|
) -> tuple:
|
@@ -357,8 +357,8 @@ def cat(
|
|
357
357
|
Args:
|
358
358
|
Input (list[num]): Input data.
|
359
359
|
w (list[list[num]]): Weight matrix of the neural network.
|
360
|
-
|
361
|
-
|
360
|
+
ACTIVATION_threshold (str): Sign for threshold comparison ('<', '>', '==', '!=').
|
361
|
+
activation_potential (num): Threshold value for comparison.
|
362
362
|
isTrain (int): Flag indicating if the function is called during training (1 for training, 0 otherwise).
|
363
363
|
|
364
364
|
Returns:
|
@@ -453,7 +453,7 @@ def Relu(
|
|
453
453
|
def evaluate(
|
454
454
|
x_test, # list[list[num]]: Test input data.
|
455
455
|
y_test, # list[num]: Test labels.
|
456
|
-
|
456
|
+
activation_potential, # list[num]: List of ACTIVATION POTENTIALS for each layer.
|
457
457
|
visualize, # visualize Testing procces or not visualize ('y' or 'n')
|
458
458
|
W # list[list[num]]: Weight matrix of the neural network.
|
459
459
|
) -> tuple:
|
@@ -463,7 +463,7 @@ def evaluate(
|
|
463
463
|
Args:
|
464
464
|
x_test (list[list[num]]): Test input data.
|
465
465
|
y_test (list[num]): Test labels.
|
466
|
-
|
466
|
+
activation_potential (float): Input activation potential
|
467
467
|
visualize (str): Visualize test progress ? ('y' or 'n')
|
468
468
|
W (list[list[num]]): Weight matrix of the neural network.
|
469
469
|
|
@@ -495,9 +495,9 @@ def evaluate(
|
|
495
495
|
neural_layer = normalization(neural_layer)
|
496
496
|
|
497
497
|
if layers[index] == 'fex':
|
498
|
-
neural_layer = fex(neural_layer, W[index],
|
498
|
+
neural_layer = fex(neural_layer, W[index], activation_potential, 0, 0)[0]
|
499
499
|
if layers[index] == 'cat':
|
500
|
-
neural_layer = cat(neural_layer, W[index],
|
500
|
+
neural_layer = cat(neural_layer, W[index], activation_potential, 0, 0)[0]
|
501
501
|
|
502
502
|
for i, w in enumerate(Wc):
|
503
503
|
W[i] = np.copy(w)
|
@@ -572,7 +572,7 @@ def evaluate(
|
|
572
572
|
|
573
573
|
except:
|
574
574
|
|
575
|
-
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)
|
576
576
|
return 'e'
|
577
577
|
|
578
578
|
|
@@ -582,7 +582,7 @@ def evaluate(
|
|
582
582
|
def save_model(model_name,
|
583
583
|
model_type,
|
584
584
|
class_count,
|
585
|
-
|
585
|
+
activation_potential,
|
586
586
|
test_acc,
|
587
587
|
weights_type,
|
588
588
|
weights_format,
|
@@ -591,13 +591,13 @@ def save_model(model_name,
|
|
591
591
|
):
|
592
592
|
|
593
593
|
infosave_model = """
|
594
|
-
Function to save a
|
594
|
+
Function to save a pruning learning model.
|
595
595
|
|
596
596
|
Arguments:
|
597
597
|
model_name (str): Name of the model.
|
598
598
|
model_type (str): Type of the model.(options: PLAN)
|
599
599
|
class_count (int): Number of classes.
|
600
|
-
|
600
|
+
activation_potential (float): Activation potential.
|
601
601
|
test_acc (float): Test accuracy of the model.
|
602
602
|
weights_type (str): Type of weights to save (options: 'txt', 'npy', 'mat').
|
603
603
|
WeightFormat (str): Format of the weights (options: 'd', 'f', 'raw').
|
@@ -641,7 +641,7 @@ def save_model(model_name,
|
|
641
641
|
'LAYERS': layers,
|
642
642
|
'LAYER COUNT': len(layers),
|
643
643
|
'CLASS COUNT': class_count,
|
644
|
-
'
|
644
|
+
'ACTIVATION POTENTIAL': activation_potential,
|
645
645
|
'NEURON COUNT': NeuronCount,
|
646
646
|
'SYNAPSE COUNT': SynapseCount,
|
647
647
|
'TEST ACCURACY': test_acc,
|
@@ -738,7 +738,7 @@ def load_model(model_name,
|
|
738
738
|
model_path,
|
739
739
|
):
|
740
740
|
infoload_model = """
|
741
|
-
Function to load a
|
741
|
+
Function to load a pruning learning model.
|
742
742
|
|
743
743
|
Arguments:
|
744
744
|
model_name (str): Name of the model.
|
@@ -746,7 +746,7 @@ def load_model(model_name,
|
|
746
746
|
log_type (str): Type of log to load (options: 'csv', 'txt', 'hdf5').
|
747
747
|
|
748
748
|
Returns:
|
749
|
-
lists: W(list[num]),
|
749
|
+
lists: W(list[num]), activation_potential, df (DataFrame of the model)
|
750
750
|
"""
|
751
751
|
pass
|
752
752
|
|
@@ -766,7 +766,7 @@ def load_model(model_name,
|
|
766
766
|
layers = df['LAYERS'].tolist()
|
767
767
|
layer_count = int(df['LAYER COUNT'].iloc[0])
|
768
768
|
class_count = int(df['CLASS COUNT'].iloc[0])
|
769
|
-
|
769
|
+
activation_potential = int(df['ACTIVATION POTENTIAL'].iloc[0])
|
770
770
|
NeuronCount = int(df['NEURON COUNT'].iloc[0])
|
771
771
|
SynapseCount = int(df['SYNAPSE COUNT'].iloc[0])
|
772
772
|
test_acc = int(df['TEST ACCURACY'].iloc[0])
|
@@ -789,12 +789,12 @@ def load_model(model_name,
|
|
789
789
|
else:
|
790
790
|
raise ValueError(Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy' or 'mat' from: load_model." + infoload_model + Style.RESET_ALL)
|
791
791
|
print(Fore.GREEN + "Model loaded succesfully" + Style.RESET_ALL)
|
792
|
-
return W,
|
792
|
+
return W,activation_potential,df
|
793
793
|
|
794
794
|
def predict_model_ssd(Input,model_name,model_path):
|
795
795
|
|
796
796
|
infopredict_model_ssd = """
|
797
|
-
Function to make a prediction using a divided pruning
|
797
|
+
Function to make a prediction using a divided pruning learning artificial neural network (PLAN).
|
798
798
|
|
799
799
|
Arguments:
|
800
800
|
Input (list or ndarray): Input data for the model (single vector or single matrix).
|
@@ -803,7 +803,7 @@ def predict_model_ssd(Input,model_name,model_path):
|
|
803
803
|
Returns:
|
804
804
|
ndarray: Output from the model.
|
805
805
|
"""
|
806
|
-
W,
|
806
|
+
W,activation_potential = load_model(model_name,model_path)[0:2]
|
807
807
|
|
808
808
|
layers = ['fex','cat']
|
809
809
|
|
@@ -819,9 +819,9 @@ def predict_model_ssd(Input,model_name,model_path):
|
|
819
819
|
neural_layer = normalization(neural_layer)
|
820
820
|
|
821
821
|
if layers[index] == 'fex':
|
822
|
-
neural_layer = fex(neural_layer, W[index],
|
822
|
+
neural_layer = fex(neural_layer, W[index], activation_potential,0, 0)[0]
|
823
823
|
if layers[index] == 'cat':
|
824
|
-
neural_layer = cat(neural_layer, W[index],
|
824
|
+
neural_layer = cat(neural_layer, W[index], activation_potential, 0, 0)[0]
|
825
825
|
except:
|
826
826
|
print(Fore.RED + "ERROR: The input was probably entered incorrectly. from: predict_model_ssd" + infopredict_model_ssd + Style.RESET_ALL)
|
827
827
|
return 'e'
|
@@ -830,15 +830,15 @@ def predict_model_ssd(Input,model_name,model_path):
|
|
830
830
|
return neural_layer
|
831
831
|
|
832
832
|
|
833
|
-
def predict_model_ram(Input,
|
833
|
+
def predict_model_ram(Input,activation_potential,W):
|
834
834
|
|
835
835
|
infopredict_model_ram = """
|
836
|
-
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).
|
837
837
|
from weights and parameters stored in memory.
|
838
838
|
|
839
839
|
Arguments:
|
840
840
|
Input (list or ndarray): Input data for the model (single vector or single matrix).
|
841
|
-
|
841
|
+
activation_potential (float): Activation potential.
|
842
842
|
W (list of ndarrays): Weights of the model.
|
843
843
|
|
844
844
|
Returns:
|
@@ -859,9 +859,9 @@ def predict_model_ram(Input,action_potential,W):
|
|
859
859
|
neural_layer = normalization(neural_layer)
|
860
860
|
|
861
861
|
if layers[index] == 'fex':
|
862
|
-
neural_layer = fex(neural_layer, W[index],
|
862
|
+
neural_layer = fex(neural_layer, W[index], activation_potential,0, 0)[0]
|
863
863
|
if layers[index] == 'cat':
|
864
|
-
neural_layer = cat(neural_layer, W[index],
|
864
|
+
neural_layer = cat(neural_layer, W[index], activation_potential, 0, 0)[0]
|
865
865
|
|
866
866
|
except:
|
867
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=-41P4Rj5_-PrYWYXcaavYHlu8AninycX3FJRs33JrQQ,33028
|
3
|
-
pyerualjetwork-2.0.4.dist-info/METADATA,sha256=GVCzZR_GTYxGb4TYWyFj4ff4dusUzBmtwt4ceGnyI-w,431
|
4
|
-
pyerualjetwork-2.0.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
5
|
-
pyerualjetwork-2.0.4.dist-info/top_level.txt,sha256=G0Al3HuNJ88434XneyDtRKAIUaLCizOFYFYNhd7e2OM,5
|
6
|
-
pyerualjetwork-2.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|