pyerualjetwork 4.6.6__py3-none-any.whl → 4.6.8b0__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.
- pyerualjetwork/__init__.py +1 -1
- pyerualjetwork/activation_functions.py +2 -2
- pyerualjetwork/activation_functions_cuda.py +2 -6
- pyerualjetwork/data_operations.py +8 -6
- pyerualjetwork/data_operations_cuda.py +8 -6
- pyerualjetwork/model_operations.py +85 -85
- pyerualjetwork/model_operations_cuda.py +81 -79
- pyerualjetwork/plan.py +5 -0
- pyerualjetwork/plan_cuda.py +5 -0
- {pyerualjetwork-4.6.6.dist-info → pyerualjetwork-4.6.8b0.dist-info}/METADATA +1 -1
- pyerualjetwork-4.6.8b0.dist-info/RECORD +25 -0
- pyerualjetwork-4.6.6.dist-info/RECORD +0 -25
- {pyerualjetwork-4.6.6.dist-info → pyerualjetwork-4.6.8b0.dist-info}/WHEEL +0 -0
- {pyerualjetwork-4.6.6.dist-info → pyerualjetwork-4.6.8b0.dist-info}/top_level.txt +0 -0
pyerualjetwork/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
__version__ = "4.6.
|
1
|
+
__version__ = "4.6.8b0"
|
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
|
@@ -7,7 +7,7 @@ import warnings
|
|
7
7
|
|
8
8
|
def all_activations():
|
9
9
|
|
10
|
-
activations_list = ['linear', 'sigmoid', 'relu', 'tanh', 'circular', 'spiral', 'swish', 'sin_plus', 'mod_circular', 'tanh_circular', 'leaky_relu', 'softplus', 'elu', 'gelu', 'selu', 'sinakt', 'p_squared', 'sglu', 'dlrelu', 'exsig', 'acos', 'gla', 'srelu', 'qelu', 'isra', 'waveakt', 'arctan', 'bent_identity', 'sech', 'softsign', 'pwl', 'cubic', 'gaussian', 'sine', 'tanh_square', 'mod_sigmoid', 'quartic', 'square_quartic', 'cubic_quadratic', '
|
10
|
+
activations_list = ['linear', 'sigmoid', 'relu', 'tanh', 'circular', 'spiral', 'swish', 'sin_plus', 'mod_circular', 'tanh_circular', 'leaky_relu', 'softplus', 'elu', 'gelu', 'selu', 'sinakt', 'p_squared', 'sglu', 'dlrelu', 'exsig', 'acos', 'gla', 'srelu', 'qelu', 'isra', 'waveakt', 'arctan', 'bent_identity', 'sech', 'softsign', 'pwl', 'cubic', 'gaussian', 'sine', 'tanh_square', 'mod_sigmoid', 'quartic', 'square_quartic', 'cubic_quadratic', 'sine_square', 'logarithmic', 'scaled_cubic', 'sine_offset']
|
11
11
|
|
12
12
|
return activations_list
|
13
13
|
|
@@ -279,7 +279,7 @@ def apply_activation(Input, activation_list):
|
|
279
279
|
|
280
280
|
activation_outputs = np.array([activation_functions[act](origin_input) for act in valid_activations])
|
281
281
|
|
282
|
-
return
|
282
|
+
return np.sum(activation_outputs, axis=0)
|
283
283
|
|
284
284
|
except Exception as e:
|
285
285
|
warnings.warn(f"Error in activation processing: {str(e)}", RuntimeWarning)
|
@@ -6,7 +6,7 @@ import warnings
|
|
6
6
|
|
7
7
|
def all_activations():
|
8
8
|
|
9
|
-
activations_list = ['linear', 'sigmoid', 'relu', 'tanh', 'circular', 'spiral', 'swish', 'sin_plus', 'mod_circular', 'tanh_circular', 'leaky_relu', 'softplus', 'elu', 'gelu', 'selu', 'sinakt', 'p_squared', 'sglu', 'dlrelu', 'exsig', 'acos', 'gla', 'srelu', 'qelu', 'isra', 'waveakt', 'arctan', 'bent_identity', 'sech', 'softsign', 'pwl', 'cubic', 'gaussian', 'sine', 'tanh_square', 'mod_sigmoid', 'quartic', 'square_quartic', 'cubic_quadratic', '
|
9
|
+
activations_list = ['linear', 'sigmoid', 'relu', 'tanh', 'circular', 'spiral', 'swish', 'sin_plus', 'mod_circular', 'tanh_circular', 'leaky_relu', 'softplus', 'elu', 'gelu', 'selu', 'sinakt', 'p_squared', 'sglu', 'dlrelu', 'exsig', 'acos', 'gla', 'srelu', 'qelu', 'isra', 'waveakt', 'arctan', 'bent_identity', 'sech', 'softsign', 'pwl', 'cubic', 'gaussian', 'sine', 'tanh_square', 'mod_sigmoid', 'quartic', 'square_quartic', 'cubic_quadratic', 'sine_square', 'logarithmic', 'scaled_cubic', 'sine_offset']
|
10
10
|
|
11
11
|
return activations_list
|
12
12
|
|
@@ -202,9 +202,6 @@ def square_quartic(x):
|
|
202
202
|
def cubic_quadratic(x):
|
203
203
|
return x**3 * (x**2)
|
204
204
|
|
205
|
-
def exp_cubic(x):
|
206
|
-
return cp.exp(x**3)
|
207
|
-
|
208
205
|
def sine_square(x):
|
209
206
|
return cp.sin(x)**2
|
210
207
|
|
@@ -266,7 +263,6 @@ def apply_activation(Input, activation_list):
|
|
266
263
|
'quartic': quartic,
|
267
264
|
'square_quartic': square_quartic,
|
268
265
|
'cubic_quadratic': cubic_quadratic,
|
269
|
-
'exp_cubic': exp_cubic,
|
270
266
|
'sine_square': sine_square,
|
271
267
|
'logarithmic': logarithmic,
|
272
268
|
'scaled_cubic': lambda x: scaled_cubic(x, 1.0),
|
@@ -282,7 +278,7 @@ def apply_activation(Input, activation_list):
|
|
282
278
|
|
283
279
|
activation_outputs = cp.array([activation_functions[act](origin_input) for act in valid_activations])
|
284
280
|
|
285
|
-
return
|
281
|
+
return cp.sum(activation_outputs, axis=0)
|
286
282
|
|
287
283
|
except Exception as e:
|
288
284
|
warnings.warn(f"Error in activation processing: {str(e)}", RuntimeWarning)
|
@@ -379,22 +379,24 @@ dtype=np.float32):
|
|
379
379
|
|
380
380
|
|
381
381
|
def non_neg_normalization(
|
382
|
-
Input,
|
382
|
+
Input,
|
383
383
|
dtype=np.float32
|
384
384
|
):
|
385
385
|
"""
|
386
386
|
Normalizes the input data [0-1] range.
|
387
|
-
|
388
387
|
Args:
|
389
388
|
Input (numpy): Input data to be normalized.
|
390
|
-
|
391
|
-
dtype (numpy.dtype): Data type for the arrays. cp.float32 by default. Example: cp.float64 or cp.float16.
|
392
|
-
|
389
|
+
dtype (numpy.dtype): Data type for the arrays. np.float32 by default. Example: np.float64 or np.float16.
|
393
390
|
Returns:
|
394
391
|
(numpy) Scaled input data after normalization.
|
395
392
|
"""
|
393
|
+
Input = Input.astype(dtype, copy=False)
|
394
|
+
MaxAbs = np.max(np.abs(Input))
|
396
395
|
|
397
|
-
|
396
|
+
if np.all(Input == Input.flat[0]):
|
397
|
+
randomization = np.random.random(Input.shape).astype(dtype)
|
398
|
+
return randomization
|
399
|
+
|
398
400
|
return (Input + MaxAbs) / (2 * MaxAbs)
|
399
401
|
|
400
402
|
|
@@ -420,22 +420,24 @@ def normalization(
|
|
420
420
|
|
421
421
|
|
422
422
|
def non_neg_normalization(
|
423
|
-
Input,
|
424
|
-
dtype=
|
423
|
+
Input,
|
424
|
+
dtype=np.float32
|
425
425
|
):
|
426
426
|
"""
|
427
427
|
Normalizes the input data [0-1] range.
|
428
|
-
|
429
428
|
Args:
|
430
429
|
Input (cupy): Input data to be normalized.
|
431
|
-
|
432
430
|
dtype (cupy.dtype): Data type for the arrays. cp.float32 by default. Example: cp.float64 or cp.float16.
|
433
|
-
|
434
431
|
Returns:
|
435
432
|
(cupy) Scaled input data after normalization.
|
436
433
|
"""
|
434
|
+
Input = Input.astype(dtype, copy=False)
|
435
|
+
MaxAbs = cp.max(cp.abs(Input))
|
437
436
|
|
438
|
-
|
437
|
+
if cp.all(Input == Input.flat[0]):
|
438
|
+
randomization = cp.random.random(Input.shape).astype(dtype)
|
439
|
+
return randomization
|
440
|
+
|
439
441
|
return (Input + MaxAbs) / (2 * MaxAbs)
|
440
442
|
|
441
443
|
|
@@ -55,6 +55,13 @@ def save_model(model_name,
|
|
55
55
|
if model_type != 'PLAN' and model_type != 'MLP':
|
56
56
|
raise ValueError("model_type parameter must be 'PLAN' or 'MLP'.")
|
57
57
|
|
58
|
+
if isinstance(activation_potentiation, str):
|
59
|
+
activation_potentiation = [activation_potentiation]
|
60
|
+
else:
|
61
|
+
activation_potentiation = [item if isinstance(item, list) else [item] for item in activation_potentiation]
|
62
|
+
|
63
|
+
activation = activation_potentiation.copy()
|
64
|
+
|
58
65
|
if test_acc != None:
|
59
66
|
test_acc= float(test_acc)
|
60
67
|
|
@@ -82,6 +89,7 @@ def save_model(model_name,
|
|
82
89
|
sys.exit()
|
83
90
|
|
84
91
|
elif model_type == 'MLP':
|
92
|
+
|
85
93
|
class_count = W[-1].shape[0]
|
86
94
|
|
87
95
|
NeuronCount.append(np.shape(W[0])[1])
|
@@ -95,33 +103,34 @@ def save_model(model_name,
|
|
95
103
|
print(Fore.RED + "ERROR: Weight matrices have a problem from: save_model" + Style.RESET_ALL)
|
96
104
|
sys.exit()
|
97
105
|
|
106
|
+
|
98
107
|
SynapseCount.append(' ')
|
99
108
|
|
100
|
-
|
101
|
-
|
109
|
+
activation.append('')
|
110
|
+
activation.insert(0, '')
|
102
111
|
|
103
|
-
if
|
104
|
-
|
105
|
-
|
112
|
+
if len(activation) == 1 and model_type == 'PLAN':
|
113
|
+
activation = [activation]
|
114
|
+
activation.append('')
|
106
115
|
|
107
|
-
if len(
|
108
|
-
for i in range(len(
|
116
|
+
if len(activation) > len(NeuronCount):
|
117
|
+
for i in range(len(activation) - len(NeuronCount)):
|
109
118
|
NeuronCount.append('')
|
110
|
-
|
111
|
-
if len(
|
112
|
-
for i in range(len(
|
119
|
+
|
120
|
+
if len(activation) > len(SynapseCount):
|
121
|
+
for i in range(len(activation) - len(SynapseCount)):
|
113
122
|
SynapseCount.append('')
|
114
123
|
|
115
124
|
|
116
125
|
if scaler_params != None:
|
117
126
|
|
118
|
-
if len(scaler_params) > len(
|
127
|
+
if len(scaler_params) > len(activation):
|
119
128
|
|
120
|
-
|
129
|
+
activation += ['']
|
121
130
|
|
122
|
-
elif len(
|
131
|
+
elif len(activation) > len(scaler_params):
|
123
132
|
|
124
|
-
for i in range(len(
|
133
|
+
for i in range(len(activation) - len(scaler_params)):
|
125
134
|
|
126
135
|
scaler_params.append(' ')
|
127
136
|
|
@@ -136,70 +145,62 @@ def save_model(model_name,
|
|
136
145
|
'WEIGHTS FORMAT': weights_format,
|
137
146
|
'MODEL PATH': model_path,
|
138
147
|
'STANDARD SCALER': scaler_params,
|
139
|
-
'ACTIVATION POTENTIATION':
|
148
|
+
'ACTIVATION POTENTIATION': activation
|
140
149
|
}
|
141
150
|
|
142
151
|
df = pd.DataFrame(data)
|
143
152
|
df.to_pickle(model_path + model_name + '.pkl')
|
144
153
|
|
145
|
-
|
146
|
-
else: max_file = 1
|
147
|
-
|
148
|
-
for i in range(max_file):
|
149
|
-
|
150
|
-
if max_file > 1: weight = W[i]
|
151
|
-
else: weight = W
|
154
|
+
try:
|
152
155
|
|
153
|
-
|
156
|
+
if weights_type == 'txt' and weights_format == 'f':
|
154
157
|
|
155
|
-
|
158
|
+
np.savetxt(model_path + model_name + f'_weights.txt', W, fmt='%f')
|
156
159
|
|
157
|
-
|
160
|
+
if weights_type == 'txt' and weights_format == 'raw':
|
158
161
|
|
159
|
-
|
162
|
+
np.savetxt(model_path + model_name + f'_weights.txt', W)
|
160
163
|
|
161
|
-
|
164
|
+
###
|
162
165
|
|
163
|
-
|
166
|
+
|
167
|
+
if weights_type == 'pkl' and weights_format == 'f':
|
164
168
|
|
165
|
-
|
166
|
-
|
169
|
+
with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
|
170
|
+
pickle.dump(W.astype(float), f)
|
167
171
|
|
168
|
-
|
169
|
-
|
172
|
+
if weights_type == 'pkl' and weights_format =='raw':
|
173
|
+
|
174
|
+
with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
|
175
|
+
pickle.dump(W, f)
|
170
176
|
|
171
|
-
|
172
|
-
|
173
|
-
with open(model_path + model_name + f'weights{i}.pkl', 'wb') as f:
|
174
|
-
pickle.dump(weight, f)
|
177
|
+
###
|
175
178
|
|
176
|
-
|
179
|
+
if weights_type == 'npy' and weights_format == 'f':
|
177
180
|
|
178
|
-
|
181
|
+
np.save(model_path + model_name + f'_weights.npy', W, W.astype(float))
|
179
182
|
|
180
|
-
|
183
|
+
if weights_type == 'npy' and weights_format == 'raw':
|
181
184
|
|
182
|
-
|
185
|
+
np.save(model_path + model_name + f'_weights.npy', W)
|
183
186
|
|
184
|
-
|
187
|
+
###
|
185
188
|
|
186
|
-
|
189
|
+
if weights_type == 'mat' and weights_format == 'f':
|
187
190
|
|
188
|
-
|
191
|
+
w = {'w': W.astype(float)}
|
192
|
+
io.savemat(model_path + model_name + f'_weights.mat', w)
|
189
193
|
|
190
|
-
|
191
|
-
|
194
|
+
if weights_type == 'mat' and weights_format == 'raw':
|
195
|
+
|
196
|
+
w = {'w': W}
|
197
|
+
io.savemat(model_path + model_name + f'_weights.mat', w)
|
192
198
|
|
193
|
-
|
194
|
-
|
195
|
-
w = {'w': weight}
|
196
|
-
io.savemat(model_path + model_name + f'weights{i}.mat', w)
|
199
|
+
except:
|
197
200
|
|
198
|
-
|
201
|
+
print(Fore.RED + "ERROR: Model Weights not saved. Check the Weight parameters. SaveFilePath expl: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: save_model" + Style.RESET_ALL)
|
202
|
+
sys.exit()
|
199
203
|
|
200
|
-
print(Fore.RED + "ERROR: Model Weights not saved. Check the Weight parameters. SaveFilePath expl: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: save_model" + Style.RESET_ALL)
|
201
|
-
sys.exit()
|
202
|
-
|
203
204
|
if show_info:
|
204
205
|
print(df)
|
205
206
|
|
@@ -258,33 +259,26 @@ def load_model(model_name,
|
|
258
259
|
model_name = str(df['MODEL NAME'].iloc[0])
|
259
260
|
model_type = str(df['MODEL TYPE'].iloc[0])
|
260
261
|
WeightType = str(df['WEIGHTS TYPE'].iloc[0])
|
261
|
-
layers = list(df['NEURON COUNT'])
|
262
|
-
|
263
|
-
if model_type == 'MLP': max_file = len(layers)-1
|
264
|
-
else: max_file = 1
|
265
|
-
|
266
|
-
W = []
|
267
|
-
|
268
|
-
for i in range(max_file):
|
269
|
-
|
270
|
-
if WeightType == 'txt':
|
271
|
-
W.append(np.loadtxt(model_path + model_name + f'weights{i}.txt'))
|
272
|
-
elif WeightType == 'npy':
|
273
|
-
W.append(np.load(model_path + model_name + f'weights{i}.npy'))
|
274
|
-
elif WeightType == 'mat':
|
275
|
-
W.append(sio.loadmat(model_path + model_name + f'weights{i}.mat'))
|
276
|
-
elif WeightType == 'pkl':
|
277
|
-
with open(model_path + model_name + f'weights{i}.pkl', 'rb') as f:
|
278
|
-
W = pickle.load(f)
|
279
|
-
else:
|
280
|
-
|
281
|
-
raise ValueError(
|
282
|
-
Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
|
283
|
-
|
284
|
-
if WeightType == 'mat':
|
285
|
-
W[-1] = W[-1]['w']
|
286
262
|
|
287
|
-
if model_type == '
|
263
|
+
if model_type == 'MLP': allow_pickle = True
|
264
|
+
else: allow_pickle = False
|
265
|
+
|
266
|
+
if WeightType == 'txt':
|
267
|
+
W = (np.loadtxt(model_path + model_name + f'_weights.txt'))
|
268
|
+
elif WeightType == 'npy':
|
269
|
+
W = (np.load(model_path + model_name + f'_weights.npy', allow_pickle=allow_pickle))
|
270
|
+
elif WeightType == 'mat':
|
271
|
+
W = (sio.loadmat(model_path + model_name + f'_weights.mat'))
|
272
|
+
elif WeightType == 'pkl':
|
273
|
+
with open(model_path + model_name + f'_weights.pkl', 'rb') as f:
|
274
|
+
W = pickle.load(f)
|
275
|
+
else:
|
276
|
+
|
277
|
+
raise ValueError(
|
278
|
+
Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
|
279
|
+
|
280
|
+
if WeightType == 'mat':
|
281
|
+
W = W['w']
|
288
282
|
|
289
283
|
return W, None, None, activation_potentiation, scaler_params, None, model_type
|
290
284
|
|
@@ -320,6 +314,11 @@ def predict_model_ssd(Input, model_name, model_path='', dtype=np.float32):
|
|
320
314
|
W = model[get_weights()]
|
321
315
|
model_type = model[get_model_type()]
|
322
316
|
|
317
|
+
if isinstance(activation_potentiation, str):
|
318
|
+
activation_potentiation = [activation_potentiation]
|
319
|
+
else:
|
320
|
+
activation_potentiation = [item if isinstance(item, list) else [item] for item in activation_potentiation]
|
321
|
+
|
323
322
|
Input = standard_scaler(None, Input, scaler_params)
|
324
323
|
|
325
324
|
if model_type == 'MLP':
|
@@ -343,7 +342,7 @@ def predict_model_ssd(Input, model_name, model_path='', dtype=np.float32):
|
|
343
342
|
sys.exit()
|
344
343
|
|
345
344
|
|
346
|
-
def reverse_predict_model_ssd(output, model_name, model_path=''
|
345
|
+
def reverse_predict_model_ssd(output, model_name, model_path=''):
|
347
346
|
|
348
347
|
"""
|
349
348
|
reverse prediction function from storage
|
@@ -355,8 +354,6 @@ def reverse_predict_model_ssd(output, model_name, model_path='', dtype=np.float3
|
|
355
354
|
|
356
355
|
model_path (str): Path of the model. Default: ''
|
357
356
|
|
358
|
-
dtype (numpy.dtype): Data type for the arrays. np.float32 by default. Example: np.float64 or np.float16. [fp32 for balanced devices, fp64 for strong devices, fp16 for weak devices: not reccomended!]
|
359
|
-
|
360
357
|
Returns:
|
361
358
|
ndarray: Input from the model.
|
362
359
|
"""
|
@@ -401,6 +398,11 @@ def predict_model_ram(Input, W, scaler_params=None, activation_potentiation=['li
|
|
401
398
|
|
402
399
|
Input = standard_scaler(None, Input, scaler_params)
|
403
400
|
|
401
|
+
if isinstance(activation_potentiation, str):
|
402
|
+
activation_potentiation = [activation_potentiation]
|
403
|
+
else:
|
404
|
+
activation_potentiation = [item if isinstance(item, list) else [item] for item in activation_potentiation]
|
405
|
+
|
404
406
|
if is_mlp:
|
405
407
|
|
406
408
|
layer = Input
|
@@ -421,7 +423,7 @@ def predict_model_ram(Input, W, scaler_params=None, activation_potentiation=['li
|
|
421
423
|
print(Fore.RED + "ERROR: Unexpected input or wrong model parameters from: predict_model_ram." + Style.RESET_ALL)
|
422
424
|
sys.exit()
|
423
425
|
|
424
|
-
def reverse_predict_model_ram(output, W
|
426
|
+
def reverse_predict_model_ram(output, W):
|
425
427
|
|
426
428
|
"""
|
427
429
|
reverse prediction function from memory
|
@@ -432,8 +434,6 @@ def reverse_predict_model_ram(output, W, dtype=np.float32):
|
|
432
434
|
|
433
435
|
W (list of ndarrays): Weights of the model.
|
434
436
|
|
435
|
-
dtype (numpy.dtype): Data type for the arrays. np.float32 by default. Example: np.float64 or np.float16. [fp32 for balanced devices, fp64 for strong devices, fp16 for weak devices: not reccomended!]
|
436
|
-
|
437
437
|
Returns:
|
438
438
|
ndarray: Input from the model.
|
439
439
|
"""
|
@@ -59,6 +59,13 @@ def save_model(model_name,
|
|
59
59
|
if model_type != 'PLAN' and model_type != 'MLP':
|
60
60
|
raise ValueError("model_type parameter must be 'PLAN' or 'MLP'.")
|
61
61
|
|
62
|
+
if isinstance(activation_potentiation, str):
|
63
|
+
activation_potentiation = [activation_potentiation]
|
64
|
+
else:
|
65
|
+
activation_potentiation = [item if isinstance(item, list) else [item] for item in activation_potentiation]
|
66
|
+
|
67
|
+
activation = activation_potentiation.copy()
|
68
|
+
|
62
69
|
if test_acc is not None:
|
63
70
|
test_acc= float(test_acc)
|
64
71
|
|
@@ -101,30 +108,30 @@ def save_model(model_name,
|
|
101
108
|
|
102
109
|
SynapseCount.append(' ')
|
103
110
|
|
104
|
-
|
105
|
-
|
111
|
+
activation.append('')
|
112
|
+
activation.insert(0, '')
|
106
113
|
|
107
|
-
if
|
108
|
-
|
109
|
-
|
114
|
+
if len(activation) == 1 and model_type == 'PLAN':
|
115
|
+
activation = [activation]
|
116
|
+
activation.append('')
|
110
117
|
|
111
|
-
if len(
|
112
|
-
for i in range(len(
|
118
|
+
if len(activation) > len(NeuronCount):
|
119
|
+
for i in range(len(activation) - len(NeuronCount)):
|
113
120
|
NeuronCount.append('')
|
114
121
|
|
115
|
-
if len(
|
116
|
-
for i in range(len(
|
122
|
+
if len(activation) > len(SynapseCount):
|
123
|
+
for i in range(len(activation) - len(SynapseCount)):
|
117
124
|
SynapseCount.append('')
|
118
125
|
|
119
126
|
if scaler_params != None:
|
120
127
|
|
121
|
-
if len(scaler_params) > len(
|
128
|
+
if len(scaler_params) > len(activation):
|
122
129
|
|
123
|
-
|
130
|
+
activation += ['']
|
124
131
|
|
125
|
-
elif len(
|
132
|
+
elif len(activation) > len(scaler_params):
|
126
133
|
|
127
|
-
for i in range(len(
|
134
|
+
for i in range(len(activation) - len(scaler_params)):
|
128
135
|
|
129
136
|
scaler_params.append(' ')
|
130
137
|
|
@@ -142,70 +149,62 @@ def save_model(model_name,
|
|
142
149
|
'WEIGHTS FORMAT': weights_format,
|
143
150
|
'MODEL PATH': model_path,
|
144
151
|
'STANDARD SCALER': scaler_params,
|
145
|
-
'ACTIVATION POTENTIATION':
|
152
|
+
'ACTIVATION POTENTIATION': activation
|
146
153
|
}
|
147
154
|
|
148
155
|
df = pd.DataFrame(data)
|
149
156
|
df.to_pickle(model_path + model_name + '.pkl')
|
150
157
|
|
151
|
-
|
152
|
-
else: max_file = 1
|
153
|
-
|
154
|
-
for i in range(max_file):
|
158
|
+
try:
|
155
159
|
|
156
|
-
if
|
157
|
-
else: weight = W
|
160
|
+
if weights_type == 'txt' and weights_format == 'f':
|
158
161
|
|
159
|
-
|
162
|
+
cp.savetxt(model_path + model_name + f'_weights.txt', W, fmt='%f')
|
160
163
|
|
161
|
-
|
164
|
+
if weights_type == 'txt' and weights_format == 'raw':
|
162
165
|
|
163
|
-
|
166
|
+
cp.savetxt(model_path + model_name + f'_weights.txt', W)
|
164
167
|
|
165
|
-
|
168
|
+
###
|
166
169
|
|
167
|
-
|
168
|
-
|
169
|
-
###
|
170
|
+
|
171
|
+
if weights_type == 'pkl' and weights_format == 'f':
|
170
172
|
|
171
|
-
|
172
|
-
|
173
|
+
with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
|
174
|
+
pickle.dump(W.astype(float), f)
|
173
175
|
|
174
|
-
|
175
|
-
|
176
|
+
if weights_type == 'pkl' and weights_format =='raw':
|
177
|
+
|
178
|
+
with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
|
179
|
+
pickle.dump(W, f)
|
176
180
|
|
177
|
-
|
178
|
-
|
179
|
-
with open(model_path + model_name + f'weights{i}.pkl', 'wb') as f:
|
180
|
-
pickle.dump(weight, f)
|
181
|
+
###
|
181
182
|
|
182
|
-
|
183
|
+
if weights_type == 'npy' and weights_format == 'f':
|
183
184
|
|
184
|
-
|
185
|
+
cp.save(model_path + model_name + f'_weights.npy', W, W.astype(float))
|
185
186
|
|
186
|
-
|
187
|
+
if weights_type == 'npy' and weights_format == 'raw':
|
187
188
|
|
188
|
-
|
189
|
+
cp.save(model_path + model_name + f'_weights.npy', W)
|
189
190
|
|
190
|
-
|
191
|
+
###
|
191
192
|
|
192
|
-
|
193
|
+
if weights_type == 'mat' and weights_format == 'f':
|
193
194
|
|
194
|
-
|
195
|
+
w = {'w': W.astype(float)}
|
196
|
+
io.savemat(model_path + model_name + f'_weights.mat', w)
|
195
197
|
|
196
|
-
|
197
|
-
|
198
|
+
if weights_type == 'mat' and weights_format == 'raw':
|
199
|
+
|
200
|
+
w = {'w': W}
|
201
|
+
io.savemat(model_path + model_name + f'_weights.mat', w)
|
198
202
|
|
199
|
-
|
200
|
-
|
201
|
-
w = {'w': weight}
|
202
|
-
io.savemat(model_path + model_name + f'weights{i}.mat', w)
|
203
|
+
except:
|
203
204
|
|
204
|
-
|
205
|
+
print(Fore.RED + "ERROR: Model Weights not saved. Check the Weight parameters. SaveFilePath expl: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: save_model" + Style.RESET_ALL)
|
206
|
+
sys.exit()
|
205
207
|
|
206
|
-
print(Fore.RED + "ERROR: Model Weights not saved. Check the Weight parameters. SaveFilePath expl: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: save_model" + Style.RESET_ALL)
|
207
|
-
sys.exit()
|
208
|
-
|
209
208
|
if show_info:
|
210
209
|
print(df)
|
211
210
|
|
@@ -266,33 +265,26 @@ def load_model(model_name,
|
|
266
265
|
model_name = str(df['MODEL NAME'].iloc[0])
|
267
266
|
model_type = str(df['MODEL TYPE'].iloc[0])
|
268
267
|
WeightType = str(df['WEIGHTS TYPE'].iloc[0])
|
269
|
-
layers = list(df['NEURON COUNT'])
|
270
|
-
|
271
|
-
if model_type == 'MLP': max_file = len(layers)-1
|
272
|
-
else: max_file = 1
|
273
|
-
|
274
|
-
W = []
|
275
|
-
|
276
|
-
for i in range(max_file):
|
277
|
-
|
278
|
-
if WeightType == 'txt':
|
279
|
-
W.append(cp.loadtxt(model_path + model_name + f'weights{i}.txt'))
|
280
|
-
elif WeightType == 'npy':
|
281
|
-
W.append(cp.load(model_path + model_name + f'weights{i}.npy'))
|
282
|
-
elif WeightType == 'mat':
|
283
|
-
W.append(sio.loadmat(model_path + model_name + f'weights{i}.mat'))
|
284
|
-
elif WeightType == 'pkl':
|
285
|
-
with open(model_path + model_name + f'weights{i}.pkl', 'rb') as f:
|
286
|
-
W = pickle.load(f)
|
287
|
-
else:
|
288
|
-
|
289
|
-
raise ValueError(
|
290
|
-
Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
|
291
|
-
|
292
|
-
if WeightType == 'mat':
|
293
|
-
W[-1] = W[-1]['w']
|
294
268
|
|
295
|
-
if model_type == '
|
269
|
+
if model_type == 'MLP': allow_pickle = True
|
270
|
+
else: allow_pickle = False
|
271
|
+
|
272
|
+
if WeightType == 'txt':
|
273
|
+
W = (cp.loadtxt(model_path + model_name + f'_weights.txt'))
|
274
|
+
elif WeightType == 'npy':
|
275
|
+
W = (cp.load(model_path + model_name + f'_weights.npy', allow_pickle=allow_pickle))
|
276
|
+
elif WeightType == 'mat':
|
277
|
+
W = (sio.loadmat(model_path + model_name + f'_weights.mat'))
|
278
|
+
elif WeightType == 'pkl':
|
279
|
+
with open(model_path + model_name + f'_weights.pkl', 'rb') as f:
|
280
|
+
W = pickle.load(f)
|
281
|
+
else:
|
282
|
+
|
283
|
+
raise ValueError(
|
284
|
+
Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
|
285
|
+
|
286
|
+
if WeightType == 'mat':
|
287
|
+
W = W['w']
|
296
288
|
|
297
289
|
return W, None, None, activation_potentiation, scaler_params, None, model_type
|
298
290
|
|
@@ -330,6 +322,11 @@ def predict_model_ssd(Input, model_name, model_path='', dtype=cp.float32):
|
|
330
322
|
W = model[get_weights()]
|
331
323
|
model_type = model[get_model_type()]
|
332
324
|
|
325
|
+
if isinstance(activation_potentiation, str):
|
326
|
+
activation_potentiation = [activation_potentiation]
|
327
|
+
else:
|
328
|
+
activation_potentiation = [item if isinstance(item, list) else [item] for item in activation_potentiation]
|
329
|
+
|
333
330
|
Input = standard_scaler(None, Input, scaler_params)
|
334
331
|
|
335
332
|
if model_type == 'MLP':
|
@@ -410,7 +407,12 @@ def predict_model_ram(Input, W, scaler_params=None, activation_potentiation=['li
|
|
410
407
|
from .activation_functions_cuda import apply_activation
|
411
408
|
|
412
409
|
try:
|
413
|
-
|
410
|
+
|
411
|
+
if isinstance(activation_potentiation, str):
|
412
|
+
activation_potentiation = [activation_potentiation]
|
413
|
+
else:
|
414
|
+
activation_potentiation = [item if isinstance(item, list) else [item] for item in activation_potentiation]
|
415
|
+
|
414
416
|
Input = standard_scaler(None, Input, scaler_params)
|
415
417
|
|
416
418
|
if is_mlp:
|
pyerualjetwork/plan.py
CHANGED
@@ -404,6 +404,11 @@ def evaluate(
|
|
404
404
|
|
405
405
|
if auto_normalization: x_test = normalization(x_test, dtype=x_test.dtype)
|
406
406
|
|
407
|
+
if isinstance(activation_potentiation, str):
|
408
|
+
activation_potentiation = [activation_potentiation]
|
409
|
+
else:
|
410
|
+
activation_potentiation = [item if isinstance(item, list) else [item] for item in activation_potentiation]
|
411
|
+
|
407
412
|
x_test = apply_activation(x_test, activation_potentiation)
|
408
413
|
|
409
414
|
result = x_test @ W.T
|
pyerualjetwork/plan_cuda.py
CHANGED
@@ -413,6 +413,11 @@ def evaluate(
|
|
413
413
|
|
414
414
|
if auto_normalization: x_test = normalization(x_test, dtype=x_test.dtype)
|
415
415
|
|
416
|
+
if isinstance(activation_potentiation, str):
|
417
|
+
activation_potentiation = [activation_potentiation]
|
418
|
+
else:
|
419
|
+
activation_potentiation = [item if isinstance(item, list) else [item] for item in activation_potentiation]
|
420
|
+
|
416
421
|
x_test = apply_activation(x_test, activation_potentiation)
|
417
422
|
|
418
423
|
result = x_test @ W.T
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyerualjetwork
|
3
|
-
Version: 4.6.
|
3
|
+
Version: 4.6.8b0
|
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
|
@@ -0,0 +1,25 @@
|
|
1
|
+
pyerualjetwork/__init__.py,sha256=u-vA_SDH_vmQI2fEUzbCFlIJG84uHxcir0gEXc-UvgQ,1281
|
2
|
+
pyerualjetwork/activation_functions.py,sha256=0fNOHXd490HC6gadKwb0AuBjw34dWq3GRZkg5iWO27c,7621
|
3
|
+
pyerualjetwork/activation_functions_cuda.py,sha256=X5-dtYBkGp35kyL21eLR7mbYUdttxElu-WqXmwmkV9E,7672
|
4
|
+
pyerualjetwork/data_operations.py,sha256=XKYG9-mLa3qKAXUjejuD7V8aJKjpl5PdQwKzPFjpKgs,15437
|
5
|
+
pyerualjetwork/data_operations_cuda.py,sha256=zqiHXDRtC8qDlVlN6lLoZn9uQgkm40aKFfFjWjurCxQ,17538
|
6
|
+
pyerualjetwork/fitness_functions.py,sha256=urRdeMvUhNgWxD4ZGHCRdQlIf9cTWYMvF3_aVBojRqY,1235
|
7
|
+
pyerualjetwork/help.py,sha256=nQ_YbYA2RtuafhuvkreNpX0WWL1I_nzlelwCtvei0_Y,775
|
8
|
+
pyerualjetwork/loss_functions.py,sha256=6PyBI232SQRGuFnG3LDGvnv_PUdWzT2_2mUODJiejGI,618
|
9
|
+
pyerualjetwork/loss_functions_cuda.py,sha256=C93IZJcrOpT6HMK9x1O4AHJWXYTkN5WZiqdssPbvAPk,617
|
10
|
+
pyerualjetwork/memory_operations.py,sha256=0yCOHcgiNyF4ccMcRlL1Q9F_byG4nzjhmkbpXE_yU6E,13401
|
11
|
+
pyerualjetwork/metrics.py,sha256=q7MkhnZDRbCjFBDDfUgrl8lBYnUT_1ro1LxeBq105pI,6077
|
12
|
+
pyerualjetwork/metrics_cuda.py,sha256=73h9GC7XwmnFCVzFEEiPQfF8CwHIz2wsCbxpZrJtYgw,5061
|
13
|
+
pyerualjetwork/model_operations.py,sha256=SYMXYNFFLz2YUvmp9lSKXd2L1vCwhyL_AUjL3UYCkZw,15134
|
14
|
+
pyerualjetwork/model_operations_cuda.py,sha256=GE_71JLTItAFXz8iW60QeO4XKJ8fGeHgxETmHtW9drc,16204
|
15
|
+
pyerualjetwork/plan.py,sha256=cjVblo8TxTHX-GZPvgQvJZ34nOmzxSvtCrQi9K-Mhog,23268
|
16
|
+
pyerualjetwork/plan_cuda.py,sha256=ZEU_b_EoA-zPk7Gn94L_XBZz1v4mn8DOUsjTNV6fp8Q,24230
|
17
|
+
pyerualjetwork/planeat.py,sha256=prbkUIrD37Y_b7MmTuGg4rGHXfqHIjLFMbs7TnnEy9E,44645
|
18
|
+
pyerualjetwork/planeat_cuda.py,sha256=i6WDHkUEAMK7IHNBilM29xyYWq2qvPNpF9idcAkC1EU,44650
|
19
|
+
pyerualjetwork/ui.py,sha256=JBTFYz5R24XwNKhA3GSW-oYAoiIBxAE3kFGXkvm5gqw,656
|
20
|
+
pyerualjetwork/visualizations.py,sha256=utnX9zQhzmtvBJLOLNGm2jecVVk4zHXABQdjb0XzJac,28352
|
21
|
+
pyerualjetwork/visualizations_cuda.py,sha256=gnoaaazZ-nc9E1ImqXrZBRgQ4Rnpi2qh2yGJ2eLKMlE,28807
|
22
|
+
pyerualjetwork-4.6.8b0.dist-info/METADATA,sha256=nB7S7mpl1snTt4T8QzTSs8ShpPEpny_at6JXeqW5h2c,7507
|
23
|
+
pyerualjetwork-4.6.8b0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
24
|
+
pyerualjetwork-4.6.8b0.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
|
25
|
+
pyerualjetwork-4.6.8b0.dist-info/RECORD,,
|
@@ -1,25 +0,0 @@
|
|
1
|
-
pyerualjetwork/__init__.py,sha256=uKOppTDMmBVI819Q_jQUWyvm_UZH3QzdKF3q9SCfXU0,1279
|
2
|
-
pyerualjetwork/activation_functions.py,sha256=Ms0AGBqkJuCA42ht64MSQnO54Td_1eDGquedpoBDVbc,7642
|
3
|
-
pyerualjetwork/activation_functions_cuda.py,sha256=5y1Ti3GDfDteQDCUmODwe7tAyDAUlDTKmIikChQ8d6g,7772
|
4
|
-
pyerualjetwork/data_operations.py,sha256=Y_RdxkjLEszFgeo4VDWIX1keF2syP-88KesLXA5sRyY,15280
|
5
|
-
pyerualjetwork/data_operations_cuda.py,sha256=9tyD3Bbv5__stuUampgh3_GbMhb_kmTTJmZi7BJsvuA,17381
|
6
|
-
pyerualjetwork/fitness_functions.py,sha256=urRdeMvUhNgWxD4ZGHCRdQlIf9cTWYMvF3_aVBojRqY,1235
|
7
|
-
pyerualjetwork/help.py,sha256=nQ_YbYA2RtuafhuvkreNpX0WWL1I_nzlelwCtvei0_Y,775
|
8
|
-
pyerualjetwork/loss_functions.py,sha256=6PyBI232SQRGuFnG3LDGvnv_PUdWzT2_2mUODJiejGI,618
|
9
|
-
pyerualjetwork/loss_functions_cuda.py,sha256=C93IZJcrOpT6HMK9x1O4AHJWXYTkN5WZiqdssPbvAPk,617
|
10
|
-
pyerualjetwork/memory_operations.py,sha256=0yCOHcgiNyF4ccMcRlL1Q9F_byG4nzjhmkbpXE_yU6E,13401
|
11
|
-
pyerualjetwork/metrics.py,sha256=q7MkhnZDRbCjFBDDfUgrl8lBYnUT_1ro1LxeBq105pI,6077
|
12
|
-
pyerualjetwork/metrics_cuda.py,sha256=73h9GC7XwmnFCVzFEEiPQfF8CwHIz2wsCbxpZrJtYgw,5061
|
13
|
-
pyerualjetwork/model_operations.py,sha256=fr64XCwgl1YRh5nP3sEkvQORKHb-2lF_a4KjclNkZfY,15522
|
14
|
-
pyerualjetwork/model_operations_cuda.py,sha256=-Kv8fYqHSU0L9FalOsQ7EWCwCEwjgUySObyueOqCH_o,16134
|
15
|
-
pyerualjetwork/plan.py,sha256=UyIvPmvHCHwczlc9KHolE4y6CPEeBfhnRN5yznSbnoM,23028
|
16
|
-
pyerualjetwork/plan_cuda.py,sha256=iteqgv7x9Z2Pj4vGOZs6HXS3r0bNaF_smr7ZXaOdRnw,23990
|
17
|
-
pyerualjetwork/planeat.py,sha256=prbkUIrD37Y_b7MmTuGg4rGHXfqHIjLFMbs7TnnEy9E,44645
|
18
|
-
pyerualjetwork/planeat_cuda.py,sha256=i6WDHkUEAMK7IHNBilM29xyYWq2qvPNpF9idcAkC1EU,44650
|
19
|
-
pyerualjetwork/ui.py,sha256=JBTFYz5R24XwNKhA3GSW-oYAoiIBxAE3kFGXkvm5gqw,656
|
20
|
-
pyerualjetwork/visualizations.py,sha256=utnX9zQhzmtvBJLOLNGm2jecVVk4zHXABQdjb0XzJac,28352
|
21
|
-
pyerualjetwork/visualizations_cuda.py,sha256=gnoaaazZ-nc9E1ImqXrZBRgQ4Rnpi2qh2yGJ2eLKMlE,28807
|
22
|
-
pyerualjetwork-4.6.6.dist-info/METADATA,sha256=nrasvgqmd7Tb2-NEqbkmaS4FWNIaHmyttYaLLzKm0_Q,7505
|
23
|
-
pyerualjetwork-4.6.6.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
24
|
-
pyerualjetwork-4.6.6.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
|
25
|
-
pyerualjetwork-4.6.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|