pyerualjetwork 2.2.2__py3-none-any.whl → 2.2.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_bi/__init__.py +1 -1
- plan_bi/plan_bi.py +10 -160
- plan_di/__init__.py +1 -1
- plan_di/plan_di.py +6 -104
- pyerualjetwork-2.2.4.dist-info/METADATA +8 -0
- pyerualjetwork-2.2.4.dist-info/RECORD +8 -0
- pyerualjetwork-2.2.2.dist-info/METADATA +0 -8
- pyerualjetwork-2.2.2.dist-info/RECORD +0 -8
- {pyerualjetwork-2.2.2.dist-info → pyerualjetwork-2.2.4.dist-info}/WHEEL +0 -0
- {pyerualjetwork-2.2.2.dist-info → pyerualjetwork-2.2.4.dist-info}/top_level.txt +0 -0
plan_bi/__init__.py
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
|
3
3
|
# Bu dosya, plan modülünün ana giriş noktasıdır.
|
4
4
|
|
5
|
-
from .plan_bi import auto_balancer, normalization, Softmax, Sigmoid, Relu,
|
5
|
+
from .plan_bi import auto_balancer, normalization, Softmax, Sigmoid, Relu, weight_identification, fex, fit, evaluate, save_model, load_model, predict_model_ssd, predict_model_ram, get_weights, get_df, get_preds, get_acc, get_pot, synthetic_augmentation, standard_scaler, multiple_evaluate, encode_one_hot, split, metrics, decode_one_hot, roc_curve, confusion_matrix, plot_evaluate
|
plan_bi/plan_bi.py
CHANGED
@@ -59,7 +59,6 @@ def fit(
|
|
59
59
|
x_train_size = len(x_train[0])
|
60
60
|
|
61
61
|
W = weight_identification(len(layers) - 1,len(class_count),neurons,x_train_size)
|
62
|
-
Divides, Piece = synaptic_dividing(len(class_count),W)
|
63
62
|
trained_W = [1] * len(W)
|
64
63
|
print(Fore.GREEN + "Train Started with 0 ERROR" + Style.RESET_ALL,)
|
65
64
|
start_time = time.time()
|
@@ -72,19 +71,6 @@ def fit(
|
|
72
71
|
print(Fore.RED +"ERROR304: All input matrices or vectors in x_train list, must be same size. from: fit",infoPLAN + Style.RESET_ALL)
|
73
72
|
return 'e'
|
74
73
|
|
75
|
-
|
76
|
-
for Ulindex, Ul in enumerate(class_count):
|
77
|
-
|
78
|
-
if Ul == y_train[index]:
|
79
|
-
for Windex, w in enumerate(W):
|
80
|
-
for i, ul in enumerate(Ul):
|
81
|
-
if ul == 1.0:
|
82
|
-
k = i
|
83
|
-
|
84
|
-
cs = Divides[int(k)][Windex][0]
|
85
|
-
|
86
|
-
|
87
|
-
W[Windex] = synaptic_pruning(w, cs, 'row', int(k), len(class_count), Piece[Windex], True)
|
88
74
|
|
89
75
|
neural_layer = inp
|
90
76
|
|
@@ -94,7 +80,7 @@ def fit(
|
|
94
80
|
neural_layer = normalization(neural_layer)
|
95
81
|
|
96
82
|
if Layer == 'fex':
|
97
|
-
W[Lindex] = fex(neural_layer, W[Lindex], activation_potential,
|
83
|
+
W[Lindex] = fex(neural_layer, W[Lindex], activation_potential, True, y)
|
98
84
|
|
99
85
|
|
100
86
|
for i, w in enumerate(W):
|
@@ -173,114 +159,12 @@ def weight_identification(
|
|
173
159
|
W[len(W) - 1] = np.eye(class_count)
|
174
160
|
|
175
161
|
return W
|
176
|
-
|
177
|
-
def synaptic_pruning(
|
178
|
-
w, # list[num]: Weight matrix of the neural network.
|
179
|
-
cs, # int: cs = cut_start, Synaptic connections between neurons.
|
180
|
-
key, # int: key for identifying synaptic connections.
|
181
|
-
Class, # int: Class label for the current training instance.
|
182
|
-
class_count, # int: Total number of classes in the dataset.
|
183
|
-
piece, # int: Which set of neurons will information be transferred to?
|
184
|
-
is_training # bool: Flag indicating if the function is called during training (True or False).
|
185
|
-
|
186
|
-
) -> str:
|
187
|
-
infoPruning = """
|
188
|
-
Performs synaptic pruning in a neural network model.
|
189
|
-
|
190
|
-
Args:
|
191
|
-
w (list[num]): Weight matrix of the neural network.
|
192
|
-
cs (int): Synaptic connections between neurons.
|
193
|
-
key (str): key for identifying synaptic row or col connections.
|
194
|
-
Class (int): Class label for the current training instance.
|
195
|
-
class_count (int): Total number of classes in the dataset.
|
196
|
-
piece (int): Which set of neurons will information be transferred to?
|
197
|
-
is_training (bool): Flag indicating if the function is called during training (True or False).
|
198
|
-
|
199
|
-
Returns:
|
200
|
-
numpy array: Weight matrix.
|
201
|
-
"""
|
202
|
-
|
203
|
-
|
204
|
-
Class += 1 # because index start 0
|
205
|
-
|
206
|
-
if Class != 1:
|
207
|
-
|
208
|
-
ce = cs / Class # ce(cut_end) = cs(cut_start) / current_class
|
209
|
-
|
210
|
-
if is_training == True:
|
211
|
-
|
212
|
-
p = piece
|
213
|
-
|
214
|
-
for i in range(Class - 3):
|
215
|
-
|
216
|
-
piece+=p
|
217
|
-
|
218
|
-
if Class!= 2:
|
219
|
-
ce += piece
|
220
|
-
|
221
|
-
w[int(ce)-1::-1,:] = 0
|
222
|
-
|
223
|
-
w[cs:,:] = 0
|
224
|
-
|
225
|
-
else:
|
226
|
-
|
227
|
-
if key == 'row':
|
228
|
-
|
229
|
-
w[cs:,:] = 0
|
230
|
-
|
231
|
-
elif key == 'col':
|
232
|
-
|
233
|
-
w[:,cs] = 0
|
234
|
-
|
235
|
-
else:
|
236
|
-
print(Fore.RED + "ERROR103: synaptic_pruning func's key parameter must be 'row' or 'col' from: synaptic_pruning" + infoPruning)
|
237
|
-
return 'e'
|
238
|
-
|
239
|
-
return w
|
240
|
-
|
241
|
-
def synaptic_dividing(
|
242
|
-
class_count, # int: Total number of classes in the dataset.
|
243
|
-
W # list[num]: Weight matrix list of the neural network.
|
244
|
-
) -> str:
|
245
|
-
"""
|
246
|
-
Divides the synaptic weights of a neural network model based on class count.
|
247
|
-
|
248
|
-
Args:
|
249
|
-
class_count (int): Total number of classes in the dataset.
|
250
|
-
W (list[num]): Weight matrix of the neural network.
|
251
|
-
|
252
|
-
Returns:
|
253
|
-
list: a 3D list holds informations of divided net and list of neuron groups separated by classes.
|
254
|
-
"""
|
255
|
-
|
256
|
-
|
257
|
-
Piece = [1] * len(W)
|
258
|
-
Divides = [[[0] for _ in range(len(W))] for _ in range(class_count)]
|
259
|
-
|
260
|
-
|
261
|
-
for i in range(len(W)):
|
262
|
-
|
263
|
-
Piece[i] = int(math.floor(W[i].shape[0] / class_count))
|
264
|
-
|
265
|
-
cs = 0
|
266
|
-
# j = Classes, i = Weights, [0] = CutStart.
|
267
|
-
|
268
|
-
for i in range(len(W)):
|
269
|
-
for j in range(class_count):
|
270
|
-
cs = cs + Piece[i]
|
271
|
-
Divides[j][i][0] = cs
|
272
|
-
|
273
|
-
j = 0
|
274
|
-
cs = 0
|
275
|
-
|
276
|
-
return Divides, Piece
|
277
162
|
|
278
163
|
|
279
164
|
def fex(
|
280
165
|
Input, # list[num]: Input data.
|
281
166
|
w, # list[num]: Weight matrix of the neural network.
|
282
167
|
activation_potential, # float: Threshold value for comparison.
|
283
|
-
piece, # int: Which set of neurons will information be transferred to?
|
284
168
|
is_training, # bool: Flag indicating if the function is called during training (True or False).
|
285
169
|
Class # if is during training then which class(label) ? is isnt then put None.
|
286
170
|
) -> tuple:
|
@@ -300,55 +184,21 @@ def fex(
|
|
300
184
|
|
301
185
|
if is_training == True:
|
302
186
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
w[Class,input_features_index] = Input[input_features_index]
|
187
|
+
Input[Input < activation_potential] = 0
|
188
|
+
Input[Input > activation_potential] = 1
|
189
|
+
|
190
|
+
w[Class,:] = Input
|
308
191
|
|
309
192
|
return w
|
310
193
|
|
311
194
|
else:
|
312
195
|
|
313
|
-
|
314
|
-
w = synaptic_pruning(w, PruneIndex, 'col', 0, 0, piece, is_training)
|
196
|
+
Input[Input < activation_potential] = 0
|
315
197
|
|
316
198
|
neural_layer = np.dot(w, Input)
|
317
199
|
|
318
200
|
return neural_layer
|
319
|
-
|
320
|
-
def cat(
|
321
|
-
Input, # list[num]: Input data.
|
322
|
-
w, # list[num]: Weight matrix of the neural network.
|
323
|
-
is_training, # (bool): Flag indicating if the function is called during training (True or False).
|
324
|
-
Class # (int): if is during training then which class(label) ? is isnt then put None.
|
325
|
-
) -> tuple:
|
326
|
-
"""
|
327
|
-
Applies categorization process to the input data using synaptic pruning if specified.
|
328
|
-
|
329
|
-
Args:
|
330
|
-
Input (list[num]): Input data.
|
331
|
-
w (list[num]): Weight matrix of the neural network.
|
332
|
-
is_training (bool): Flag indicating if the function is called during training (True or False).
|
333
|
-
Class (int): if is during training then which class(label) ? is isnt then put None.
|
334
|
-
Returns:
|
335
|
-
tuple: A tuple containing the neural layer (vector) result and the possibly updated weight matrix.
|
336
|
-
"""
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
if is_training == True:
|
341
|
-
|
342
|
-
w[Class,Class] += 1
|
343
|
-
|
344
|
-
return w
|
345
|
-
|
346
|
-
else:
|
347
|
-
|
348
|
-
neural_layer = np.dot(w, Input)
|
349
201
|
|
350
|
-
return neural_layer
|
351
|
-
|
352
202
|
|
353
203
|
def normalization(
|
354
204
|
Input # num: Input data to be normalized.
|
@@ -469,7 +319,7 @@ def evaluate(
|
|
469
319
|
neural_layer = normalization(neural_layer)
|
470
320
|
|
471
321
|
if layers[index] == 'fex':
|
472
|
-
neural_layer = fex(neural_layer, W[index], activation_potential,
|
322
|
+
neural_layer = fex(neural_layer, W[index], activation_potential, False, None)
|
473
323
|
if layers[index] == 'cat':
|
474
324
|
neural_layer = np.dot(W[index], neural_layer)
|
475
325
|
|
@@ -912,7 +762,7 @@ def predict_model_ssd(Input, model_name, model_path):
|
|
912
762
|
neural_layer = normalization(neural_layer)
|
913
763
|
|
914
764
|
if layers[index] == 'fex':
|
915
|
-
neural_layer = fex(neural_layer, W[index], activation_potential,
|
765
|
+
neural_layer = fex(neural_layer, W[index], activation_potential, False, None)
|
916
766
|
if layers[index] == 'cat':
|
917
767
|
neural_layer = np.dot(W[index], neural_layer)
|
918
768
|
except:
|
@@ -956,7 +806,7 @@ def predict_model_ram(Input, activation_potential, scaler, W):
|
|
956
806
|
neural_layer = normalization(neural_layer)
|
957
807
|
|
958
808
|
if layers[index] == 'fex':
|
959
|
-
neural_layer = fex(neural_layer, W[index], activation_potential,
|
809
|
+
neural_layer = fex(neural_layer, W[index], activation_potential, False, None)
|
960
810
|
if layers[index] == 'cat':
|
961
811
|
neural_layer = np.dot(W[index], neural_layer)
|
962
812
|
|
@@ -1492,4 +1342,4 @@ def get_acc():
|
|
1492
1342
|
|
1493
1343
|
def get_pot():
|
1494
1344
|
|
1495
|
-
return 1
|
1345
|
+
return 1
|
plan_di/__init__.py
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
|
3
3
|
# Bu dosya, plan modülünün ana giriş noktasıdır.
|
4
4
|
|
5
|
-
from .plan_di import auto_balancer, normalization, Softmax, Sigmoid, Relu,
|
5
|
+
from .plan_di import auto_balancer, normalization, Softmax, Sigmoid, Relu, weight_identification, fex, fit, evaluate, save_model, load_model, predict_model_ssd, predict_model_ram, get_weights, get_df, get_preds, get_acc, synthetic_augmentation, standard_scaler, multiple_evaluate, encode_one_hot, split, metrics, decode_one_hot, roc_curve, confusion_matrix, plot_evaluate
|
plan_di/plan_di.py
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
|
2
|
+
import time
|
3
|
+
from colorama import Fore
|
1
4
|
"""
|
2
5
|
Created on Thu Jun 12 00:00:00 2024
|
3
6
|
|
@@ -155,112 +158,10 @@ def weight_identification(
|
|
155
158
|
return W
|
156
159
|
|
157
160
|
|
158
|
-
def synaptic_pruning(
|
159
|
-
w, # num: Weight matrix of the neural network.
|
160
|
-
cs, # int: cs = cut_start, Synaptic connections between neurons.
|
161
|
-
key, # int: key for identifying synaptic connections.
|
162
|
-
Class, # int: Class label for the current training instance.
|
163
|
-
class_count, # int: Total number of classes in the dataset.
|
164
|
-
piece, # int: Which set of neurons will information be transferred to?
|
165
|
-
# bool: Flag indicating if the function is called during training (True or False).
|
166
|
-
is_training
|
167
|
-
|
168
|
-
) -> str:
|
169
|
-
infoPruning = """
|
170
|
-
Performs synaptic pruning in a neural network model.
|
171
|
-
|
172
|
-
Args:
|
173
|
-
w (list[num]): Weight matrix of the neural network.
|
174
|
-
cs (list[num]): Synaptic connections between neurons.
|
175
|
-
key (str): key for identifying synaptic row or col connections.
|
176
|
-
Class (int): Class label for the current training instance.
|
177
|
-
class_count (int): Total number of classes in the dataset.
|
178
|
-
piece (int): Which set of neurons will information be transferred to?
|
179
|
-
is_training (bool): Flag indicating if the function is called during training (True or False).
|
180
|
-
|
181
|
-
Returns:
|
182
|
-
numpy array: Weight matrix.
|
183
|
-
"""
|
184
|
-
|
185
|
-
Class += 1 # because index start 0
|
186
|
-
|
187
|
-
if Class != 1:
|
188
|
-
|
189
|
-
ce = cs / Class # ce(cut_end) = cs(cut_start) / current_class
|
190
|
-
|
191
|
-
if is_training == True:
|
192
|
-
|
193
|
-
p = piece
|
194
|
-
|
195
|
-
for i in range(Class - 3):
|
196
|
-
|
197
|
-
piece += p
|
198
|
-
|
199
|
-
if Class != 2:
|
200
|
-
ce += piece
|
201
|
-
|
202
|
-
w[int(ce)-1::-1, :] = 0
|
203
|
-
|
204
|
-
w[cs:, :] = 0
|
205
|
-
|
206
|
-
else:
|
207
|
-
|
208
|
-
if key == 'row':
|
209
|
-
|
210
|
-
w[cs:, :] = 0
|
211
|
-
|
212
|
-
elif key == 'col':
|
213
|
-
|
214
|
-
w[:, cs] = 0
|
215
|
-
|
216
|
-
else:
|
217
|
-
print(Fore.RED + "ERROR103: synaptic_pruning func's key parameter must be 'row' or 'col' from: synaptic_pruning" + infoPruning)
|
218
|
-
return 'e'
|
219
|
-
|
220
|
-
return w
|
221
|
-
|
222
|
-
|
223
|
-
def synaptic_dividing(
|
224
|
-
class_count, # int: Total number of classes in the dataset.
|
225
|
-
W # list[num]: Weight matrix of the neural network.
|
226
|
-
) -> str:
|
227
|
-
"""
|
228
|
-
Divides the synaptic weights of a neural network model based on class count.
|
229
|
-
|
230
|
-
Args:
|
231
|
-
class_count (int): Total number of classes in the dataset.
|
232
|
-
W (list[num]): Weight matrix of the neural network.
|
233
|
-
|
234
|
-
Returns:
|
235
|
-
list: a 3D list holds informations of divided net and list of neuron groups separated by classes.
|
236
|
-
"""
|
237
|
-
|
238
|
-
Piece = [1] * len(W)
|
239
|
-
|
240
|
-
Divides = [[[0] for _ in range(len(W))] for _ in range(class_count)]
|
241
|
-
|
242
|
-
for i in range(len(W)):
|
243
|
-
|
244
|
-
Piece[i] = int(math.floor(W[i].shape[0] / class_count))
|
245
|
-
|
246
|
-
cs = 0
|
247
|
-
|
248
|
-
for i in range(len(W)):
|
249
|
-
for j in range(class_count):
|
250
|
-
cs = cs + Piece[i]
|
251
|
-
Divides[j][i][0] = cs
|
252
|
-
|
253
|
-
j = 0
|
254
|
-
cs = 0
|
255
|
-
|
256
|
-
return Divides, Piece
|
257
|
-
|
258
|
-
|
259
161
|
def fex(
|
260
162
|
Input, # list[num]: Input data.
|
261
163
|
w, # num: Weight matrix of the neural network.
|
262
|
-
# bool: Flag indicating if the function is called during training (True or False).
|
263
|
-
is_training,
|
164
|
+
is_training, # bool: Flag indicating if the function is called during training (True or False).
|
264
165
|
Class # int: Which class is, if training.
|
265
166
|
) -> tuple:
|
266
167
|
"""
|
@@ -1414,4 +1315,5 @@ def get_preds():
|
|
1414
1315
|
|
1415
1316
|
def get_acc():
|
1416
1317
|
|
1417
|
-
return 2
|
1318
|
+
return 2
|
1319
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: pyerualjetwork
|
3
|
+
Version: 2.2.4
|
4
|
+
Summary: Code improvements (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)
|
5
|
+
Author: Hasan Can Beydili
|
6
|
+
Author-email: tchasancan@gmail.com
|
7
|
+
Keywords: model evaluation,classifcation,pruning learning artficial neural networks
|
8
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
plan_bi/__init__.py,sha256=rzDe7yWvNlwDVE6xSw8Qk51itcxT6EDBj7iiOeycxMw,475
|
2
|
+
plan_bi/plan_bi.py,sha256=rB2AFL6hbVmdlSY9zT9fpmLtn_6-jHH6U0CL3UTVBHY,45370
|
3
|
+
plan_di/__init__.py,sha256=Omxc07PXPQZOrXBD3PJQT6sPdni6NMykyiQgKVL_IZ0,466
|
4
|
+
plan_di/plan_di.py,sha256=HQqc_jheT9x8NkJ9_Fvqa8EN4ehkExVy3RqvqAwPwgU,42874
|
5
|
+
pyerualjetwork-2.2.4.dist-info/METADATA,sha256=7pltYh2VTDavGRN0w2whJ1UX_eyDmKmEbb6jzyJGY4Q,325
|
6
|
+
pyerualjetwork-2.2.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
7
|
+
pyerualjetwork-2.2.4.dist-info/top_level.txt,sha256=aaXSOcnD62fbXG1x7tw4nV50Qxx9g9zDNLK7OD4BdPE,16
|
8
|
+
pyerualjetwork-2.2.4.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: pyerualjetwork
|
3
|
-
Version: 2.2.2
|
4
|
-
Summary: 8 new functions: multiple_evaluate , encode_one_hot, split, metrics, decode_one_hot, roc_curve, confusion_matrix, plot_evaluate And Code improvements (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)
|
5
|
-
Author: Hasan Can Beydili
|
6
|
-
Author-email: tchasancan@gmail.com
|
7
|
-
Keywords: model evaluation,classifcation,pruning learning artficial neural networks
|
8
|
-
|
@@ -1,8 +0,0 @@
|
|
1
|
-
plan_bi/__init__.py,sha256=82q8bWRYqzwMrFuViQzBg7P19i6EqdV7VYBVxuQ-LV0,517
|
2
|
-
plan_bi/plan_bi.py,sha256=fNJK07y9JDVLU0GORD_RHKBjTUnVzb5ciYcQFpyiSvc,50490
|
3
|
-
plan_di/__init__.py,sha256=Eut7tVtvQaczEejYyqfQ4eqF71j69josJcY91WN_dkk,508
|
4
|
-
plan_di/plan_di.py,sha256=gPuOHLSetS7axNXrwM7J5p5E1bdmQNlmIY6NJFFfEuc,45743
|
5
|
-
pyerualjetwork-2.2.2.dist-info/METADATA,sha256=d7TAOPusH1DUCSZW6W2zgsfiwpWKoEER3M3YZU6H2k0,457
|
6
|
-
pyerualjetwork-2.2.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
7
|
-
pyerualjetwork-2.2.2.dist-info/top_level.txt,sha256=aaXSOcnD62fbXG1x7tw4nV50Qxx9g9zDNLK7OD4BdPE,16
|
8
|
-
pyerualjetwork-2.2.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|