pyerualjetwork 5.35__py3-none-any.whl → 5.37__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.
@@ -42,7 +42,7 @@ PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welco
42
42
  - Contact: tchasancan@gmail.com
43
43
  """
44
44
 
45
- __version__ = "5.35"
45
+ __version__ = "5.37"
46
46
  __update__ = """* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES
47
47
  * PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main
48
48
  * PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
@@ -31,7 +31,6 @@ PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welco
31
31
  from tqdm import tqdm
32
32
  import numpy as np
33
33
  from colorama import Fore, Style
34
- import sys
35
34
  import math
36
35
 
37
36
  def encode_one_hot(y_train, y_test=None, summary=False):
@@ -268,9 +267,8 @@ def auto_balancer(x_train, y_train, dtype=np.float32):
268
267
 
269
268
  print(Fore.GREEN + "Data Succesfully Balanced from: " + str(len(x_train)
270
269
  ) + " to: " + str(len(BalancedInputs)) + ". from: auto_balancer " + Style.RESET_ALL)
271
- except:
272
- print(Fore.RED + "ERROR: Inputs and labels must be same length check parameters")
273
- sys.exit()
270
+ except Exception as e:
271
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred {e}" + Style.RESET_ALL) from e
274
272
 
275
273
  BalancedInputs = BalancedInputs.astype(dtype, copy=False)
276
274
  BalancedLabels = BalancedLabels.astype(dtype=y_train.dtype, copy=False)
@@ -47,7 +47,6 @@ PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welco
47
47
 
48
48
  import numpy as np
49
49
  from colorama import Fore, Style
50
- import sys
51
50
  from datetime import datetime
52
51
  import pickle
53
52
  from scipy import io
@@ -128,13 +127,11 @@ def save_model(model_name,
128
127
  test_acc= float(test_acc)
129
128
 
130
129
  if weights_type != 'txt' and weights_type != 'npy' and weights_type != 'mat' and weights_type != 'pkl':
131
- print(Fore.RED + "ERROR110: Save Weight type (File Extension) Type must be 'txt' or 'npy' or 'mat' or 'pkl' from: save_model" + Style.RESET_ALL)
132
- sys.exit()
130
+ raise ValueError(Fore.RED + "ERROR: Save Weight type (File Extension) Type must be 'txt' or 'npy' or 'mat' or 'pkl' from: save_model" + Style.RESET_ALL)
133
131
 
134
132
  if weights_format != 'd' and weights_format != 'f' and weights_format != 'raw':
135
- print(Fore.RED + "ERROR111: Weight Format Type must be 'd' or 'f' or 'raw' from: save_model" + Style.RESET_ALL)
136
- sys.exit()
137
-
133
+ raise ValueError(Fore.RED + "ERROR: Weight Format Type must be 'd' or 'f' or 'raw' from: save_model" + Style.RESET_ALL)
134
+
138
135
  NeuronCount = []
139
136
  SynapseCount = []
140
137
 
@@ -145,10 +142,14 @@ def save_model(model_name,
145
142
  NeuronCount.append(np.shape(W)[1])
146
143
  NeuronCount.append(np.shape(W)[0])
147
144
  SynapseCount.append(np.shape(W)[0] * np.shape(W)[1])
148
- except:
149
-
150
- print(Fore.RED + "ERROR: Weight matrices have a problem from: save_model" + Style.RESET_ALL)
151
- sys.exit()
145
+ except AttributeError as e:
146
+ raise AttributeError(Fore.RED + "ERROR: W does not have a shape attribute. Check if W is a valid matrix." + Style.RESET_ALL) from e
147
+ except IndexError as e:
148
+ raise IndexError(Fore.RED + "ERROR: W has an unexpected shape format. Ensure it has two dimensions." + Style.RESET_ALL) from e
149
+ except (TypeError, ValueError) as e:
150
+ raise TypeError(Fore.RED + "ERROR: W is not a valid numeric matrix." + Style.RESET_ALL) from e
151
+ except Exception as e:
152
+ raise RuntimeError(Fore.RED + f"ERROR: An unexpected error occurred in save_model: {e}" + Style.RESET_ALL) from e
152
153
 
153
154
  elif model_type == 'MLP' or model_type == 'PTNN':
154
155
 
@@ -160,10 +161,14 @@ def save_model(model_name,
160
161
  try:
161
162
  NeuronCount.append(np.shape(W[i])[0])
162
163
  SynapseCount.append(np.shape(W[i])[0] * np.shape(W[i])[1])
163
- except:
164
-
165
- print(Fore.RED + "ERROR: Weight matrices have a problem from: save_model" + Style.RESET_ALL)
166
- sys.exit()
164
+ except AttributeError as e:
165
+ raise AttributeError(Fore.RED + "ERROR: W does not have a shape attribute. Check if W is a valid matrix." + Style.RESET_ALL) from e
166
+ except IndexError as e:
167
+ raise IndexError(Fore.RED + "ERROR: W has an unexpected shape format. Ensure it has two dimensions." + Style.RESET_ALL) from e
168
+ except (TypeError, ValueError) as e:
169
+ raise TypeError(Fore.RED + "ERROR: W is not a valid numeric matrix." + Style.RESET_ALL) from e
170
+ except Exception as e:
171
+ raise RuntimeError(Fore.RED + f"ERROR: An unexpected error occurred in save_model: {e}" + Style.RESET_ALL) from e
167
172
 
168
173
 
169
174
  SynapseCount.append(' ')
@@ -267,10 +272,9 @@ def save_model(model_name,
267
272
  w = {'w': W}
268
273
  io.savemat(model_path + model_name + f'_weights.mat', w)
269
274
 
270
- except:
271
275
 
272
- 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)
273
- sys.exit()
276
+ except OSError as e:
277
+ raise OSError(Fore.RED + f"ERROR: An OSError error occurred in save_model at saving weights. Maybe model name or path or administration issue: {e}" + Style.RESET_ALL) from e
274
278
 
275
279
  if show_info:
276
280
  print(df)
@@ -309,11 +313,9 @@ def load_model(model_name,
309
313
 
310
314
  df = pd.read_pickle(model_path + model_name + '.pkl')
311
315
 
312
- except:
313
-
314
- print(Fore.RED + "ERROR: Model Path or Model Name error. acceptable form: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: load_model" + Style.RESET_ALL)
316
+ except OSError as e:
317
+ raise OSError(Fore.RED + f"ERROR: An OSError error occurred in load_model at loading model params. Maybe model name or path or administration issue: {e}" + Style.RESET_ALL) from e
315
318
 
316
- sys.exit()
317
319
 
318
320
 
319
321
  scaler_params = df['STANDARD SCALER'].tolist()
@@ -357,20 +359,25 @@ def load_model(model_name,
357
359
  if model_type == 'MLP' or model_type == 'PTNN': allow_pickle = True
358
360
  else: allow_pickle = False
359
361
 
360
- if WeightType == 'txt':
361
- W = (np.loadtxt(model_path + model_name + f'_weights.txt'))
362
- elif WeightType == 'npy':
363
- W = (np.load(model_path + model_name + f'_weights.npy', allow_pickle=allow_pickle))
364
- elif WeightType == 'mat':
365
- W = (sio.loadmat(model_path + model_name + f'_weights.mat'))
366
- elif WeightType == 'pkl':
367
- with open(model_path + model_name + f'_weights.pkl', 'rb') as f:
368
- W = pickle.load(f)
369
- else:
362
+ try:
363
+ if WeightType == 'txt':
364
+ W = (np.loadtxt(model_path + model_name + f'_weights.txt'))
365
+ elif WeightType == 'npy':
366
+ W = (np.load(model_path + model_name + f'_weights.npy', allow_pickle=allow_pickle))
367
+ elif WeightType == 'mat':
368
+ W = (sio.loadmat(model_path + model_name + f'_weights.mat'))
369
+ elif WeightType == 'pkl':
370
+ with open(model_path + model_name + f'_weights.pkl', 'rb') as f:
371
+ W = pickle.load(f)
372
+ else:
373
+
374
+ raise ValueError(
375
+ Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
376
+
377
+ except OSError as e:
378
+ raise OSError(Fore.RED + f"ERROR: An OSError error occurred in load_model at loading weights. Maybe model name or path or administration issue: {e}" + Style.RESET_ALL) from e
379
+
370
380
 
371
- raise ValueError(
372
- Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
373
-
374
381
  if WeightType == 'mat':
375
382
  W = W['w']
376
383
 
@@ -448,9 +455,8 @@ def predict_from_storage(Input, model_name, model_path=''):
448
455
 
449
456
  return result
450
457
 
451
- except:
452
- print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: predict_model_storage." + Style.RESET_ALL)
453
- sys.exit()
458
+ except Exception as e:
459
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred in predict_from_storage {e}" + Style.RESET_ALL) from e
454
460
 
455
461
 
456
462
  def reverse_predict_from_storage(output, model_name, model_path=''):
@@ -476,9 +482,8 @@ def reverse_predict_from_storage(output, model_name, model_path=''):
476
482
  try:
477
483
  Input = W.T @ output
478
484
  return Input
479
- except:
480
- print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: reverse_predict_model_storage." + Style.RESET_ALL)
481
- sys.exit()
485
+ except Exception as e:
486
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred {e}" + Style.RESET_ALL) from e
482
487
 
483
488
 
484
489
 
@@ -552,9 +557,8 @@ def predict_from_memory(Input, W, scaler_params=None, activations=['linear'], ac
552
557
 
553
558
  return result
554
559
 
555
- except:
556
- print(Fore.RED + "ERROR: Unexpected input or wrong model parameters from: predict_model_memory." + Style.RESET_ALL)
557
- sys.exit()
560
+ except Exception as e:
561
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred in predict_from_memory {e}" + Style.RESET_ALL) from e
558
562
 
559
563
  def reverse_predict_from_memory(output, W):
560
564
 
@@ -575,9 +579,8 @@ def reverse_predict_from_memory(output, W):
575
579
  Input = W.T @ output
576
580
  return Input
577
581
 
578
- except:
579
- print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: reverse_predict_model_memory." + Style.RESET_ALL)
580
- sys.exit()
582
+ except Exception as e:
583
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred {e}" + Style.RESET_ALL) from e
581
584
 
582
585
 
583
586
  def get_weights():
@@ -49,7 +49,6 @@ PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welco
49
49
  import cupy as cp
50
50
  import numpy as np
51
51
  from colorama import Fore, Style
52
- import sys
53
52
  from datetime import datetime
54
53
  import pickle
55
54
  from scipy import io
@@ -139,27 +138,31 @@ def save_model(model_name,
139
138
  test_acc= float(test_acc)
140
139
 
141
140
  if weights_type != 'txt' and weights_type != 'npy' and weights_type != 'mat' and weights_type != 'pkl':
142
- print(Fore.RED + "ERROR110: Save Weight type (File Extension) Type must be 'txt' or 'npy' or 'mat' or 'pkl' from: save_model" + Style.RESET_ALL)
143
- sys.exit()
141
+ raise ValueError(Fore.RED + "ERROR: Save Weight type (File Extension) Type must be 'txt' or 'npy' or 'mat' or 'pkl' from: save_model" + Style.RESET_ALL)
144
142
 
145
143
  if weights_format != 'd' and weights_format != 'f' and weights_format != 'raw':
146
- print(Fore.RED + "ERROR111: Weight Format Type must be 'd' or 'f' or 'raw' from: save_model" + Style.RESET_ALL)
147
- sys.exit()
144
+ raise ValueError(Fore.RED + "ERROR: Weight Format Type must be 'd' or 'f' or 'raw' from: save_model" + Style.RESET_ALL)
148
145
 
149
146
  NeuronCount = []
150
147
  SynapseCount = []
151
148
 
152
149
  if model_type == 'PLAN':
153
150
  class_count = W.shape[0]
154
-
151
+
155
152
  try:
156
153
  NeuronCount.append(cp.shape(W)[1])
157
154
  NeuronCount.append(cp.shape(W)[0])
158
155
  SynapseCount.append(cp.shape(W)[0] * cp.shape(W)[1])
159
- except:
156
+
157
+ except AttributeError as e:
158
+ raise AttributeError(Fore.RED + "ERROR: W does not have a shape attribute. Check if W is a valid matrix." + Style.RESET_ALL) from e
159
+ except IndexError as e:
160
+ raise IndexError(Fore.RED + "ERROR: W has an unexpected shape format. Ensure it has two dimensions." + Style.RESET_ALL) from e
161
+ except (TypeError, ValueError) as e:
162
+ raise TypeError(Fore.RED + "ERROR: W is not a valid numeric matrix." + Style.RESET_ALL) from e
163
+ except Exception as e:
164
+ raise RuntimeError(Fore.RED + f"ERROR: An unexpected error occurred in save_model: {e}" + Style.RESET_ALL) from e
160
165
 
161
- print(Fore.RED + "ERROR: Weight matrices have a problem from: save_model" + Style.RESET_ALL)
162
- sys.exit()
163
166
 
164
167
  elif model_type == 'MLP' or model_type == 'PTNN':
165
168
 
@@ -176,10 +179,15 @@ def save_model(model_name,
176
179
  try:
177
180
  NeuronCount.append(cp.shape(W[i])[0])
178
181
  SynapseCount.append(cp.shape(W[i])[0] * cp.shape(W[i])[1])
179
- except:
180
182
 
181
- print(Fore.RED + "ERROR: Weight matrices have a problem from: save_model" + Style.RESET_ALL)
182
- sys.exit()
183
+ except AttributeError as e:
184
+ raise AttributeError(Fore.RED + "ERROR: W does not have a shape attribute. Check if W is a valid matrix." + Style.RESET_ALL) from e
185
+ except IndexError as e:
186
+ raise IndexError(Fore.RED + "ERROR: W has an unexpected shape format. Ensure it has two dimensions." + Style.RESET_ALL) from e
187
+ except (TypeError, ValueError) as e:
188
+ raise TypeError(Fore.RED + "ERROR: W is not a valid numeric matrix." + Style.RESET_ALL) from e
189
+ except Exception as e:
190
+ raise RuntimeError(Fore.RED + f"ERROR: An unexpected error occurred in save_model: {e}" + Style.RESET_ALL) from e
183
191
 
184
192
  SynapseCount.append(' ')
185
193
 
@@ -241,50 +249,53 @@ def save_model(model_name,
241
249
  df = pd.DataFrame(data)
242
250
  df.to_pickle(model_path + model_name + '.pkl')
243
251
 
252
+ try:
244
253
 
245
- if weights_type == 'txt' and weights_format == 'f':
246
-
247
- cp.savetxt(model_path + model_name + f'_weights.txt', W, fmt='%f')
254
+ if weights_type == 'txt' and weights_format == 'f':
248
255
 
249
- if weights_type == 'txt' and weights_format == 'raw':
256
+ cp.savetxt(model_path + model_name + f'_weights.txt', W, fmt='%f')
250
257
 
251
- cp.savetxt(model_path + model_name + f'_weights.txt', W)
258
+ if weights_type == 'txt' and weights_format == 'raw':
252
259
 
253
- ###
260
+ cp.savetxt(model_path + model_name + f'_weights.txt', W)
254
261
 
255
-
256
- if weights_type == 'pkl' and weights_format == 'f':
262
+ ###
257
263
 
258
- with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
259
- pickle.dump(W.astype(float), f)
264
+
265
+ if weights_type == 'pkl' and weights_format == 'f':
260
266
 
261
- if weights_type == 'pkl' and weights_format =='raw':
262
-
263
- with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
264
- pickle.dump(W, f)
267
+ with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
268
+ pickle.dump(W.astype(float), f)
265
269
 
266
- ###
270
+ if weights_type == 'pkl' and weights_format =='raw':
271
+
272
+ with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
273
+ pickle.dump(W, f)
267
274
 
268
- if weights_type == 'npy' and weights_format == 'f':
275
+ ###
269
276
 
270
- cp.save(model_path + model_name + f'_weights.npy', W, W.astype(float))
277
+ if weights_type == 'npy' and weights_format == 'f':
271
278
 
272
- if weights_type == 'npy' and weights_format == 'raw':
279
+ cp.save(model_path + model_name + f'_weights.npy', W, W.astype(float))
273
280
 
274
- cp.save(model_path + model_name + f'_weights.npy', W)
281
+ if weights_type == 'npy' and weights_format == 'raw':
275
282
 
276
- ###
283
+ cp.save(model_path + model_name + f'_weights.npy', W)
277
284
 
278
- if weights_type == 'mat' and weights_format == 'f':
285
+ ###
279
286
 
280
- w = {'w': W.astype(float)}
281
- io.savemat(model_path + model_name + f'_weights.mat', w)
287
+ if weights_type == 'mat' and weights_format == 'f':
282
288
 
283
- if weights_type == 'mat' and weights_format == 'raw':
284
-
285
- w = {'w': W}
286
- io.savemat(model_path + model_name + f'_weights.mat', w)
289
+ w = {'w': W.astype(float)}
290
+ io.savemat(model_path + model_name + f'_weights.mat', w)
287
291
 
292
+ if weights_type == 'mat' and weights_format == 'raw':
293
+
294
+ w = {'w': W}
295
+ io.savemat(model_path + model_name + f'_weights.mat', w)
296
+
297
+ except OSError as e:
298
+ raise OSError(Fore.RED + f"ERROR: An OSError error occurred in save_model at saving weights. Maybe model name or path or administration issue: {e}" + Style.RESET_ALL) from e
288
299
 
289
300
  if show_info:
290
301
  print(df)
@@ -322,11 +333,8 @@ def load_model(model_name,
322
333
 
323
334
  df = pd.read_pickle(model_path + model_name + '.pkl')
324
335
 
325
- except:
326
-
327
- print(Fore.RED + "ERROR: Model Path or Model Name error. acceptable form: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: load_model" + Style.RESET_ALL)
328
-
329
- sys.exit()
336
+ except OSError as e:
337
+ raise OSError(Fore.RED + f"ERROR: An OSError error occurred in load_model at loading model params. Maybe model name or path or administration issue: {e}" + Style.RESET_ALL) from e
330
338
 
331
339
 
332
340
  scaler_params_cpu = df['STANDARD SCALER'].tolist()
@@ -356,7 +364,6 @@ def load_model(model_name,
356
364
  activation_potentiation = [x for x in activation_potentiation if not (isinstance(x, float) and np.isnan(x))]
357
365
  activation_potentiation = [item for item in activation_potentiation if item != '']
358
366
 
359
-
360
367
  device_version = __version__
361
368
 
362
369
  try:
@@ -374,27 +381,34 @@ def load_model(model_name,
374
381
  if model_type == 'MLP' or model_type == 'PTNN': allow_pickle = True
375
382
  else: allow_pickle = False
376
383
 
377
- if WeightType == 'txt':
378
- W = (np.loadtxt(model_path + model_name + f'_weights.txt'))
379
- elif WeightType == 'npy':
380
- W = (np.load(model_path + model_name + f'_weights.npy', allow_pickle=allow_pickle))
381
- elif WeightType == 'mat':
382
- W = (sio.loadmat(model_path + model_name + f'_weights.mat'))
383
- elif WeightType == 'pkl':
384
- with open(model_path + model_name + f'_weights.pkl', 'rb') as f:
385
- W = pickle.load(f)
386
- else:
387
-
388
- raise ValueError(
384
+ try:
385
+ if WeightType == 'txt':
386
+ W = (np.loadtxt(model_path + model_name + f'_weights.txt'))
387
+ elif WeightType == 'npy':
388
+ W = (np.load(model_path + model_name + f'_weights.npy', allow_pickle=allow_pickle))
389
+ elif WeightType == 'mat':
390
+ W = (sio.loadmat(model_path + model_name + f'_weights.mat'))
391
+ elif WeightType == 'pkl':
392
+ with open(model_path + model_name + f'_weights.pkl', 'rb') as f:
393
+ W = pickle.load(f)
394
+ else:
395
+ raise ValueError(
389
396
  Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
397
+
398
+ except OSError as e:
399
+ raise OSError(Fore.RED + f"ERROR: An OSError error occurred in load_model at loading weights. Maybe model name or path or administration issue: {e}" + Style.RESET_ALL) from e
400
+
390
401
 
391
402
  if WeightType == 'mat':
392
403
  W = W['w']
393
404
 
394
- if model_type == 'MLP':
405
+ if model_type == 'MLP' or model_type == 'PTNN':
395
406
  W = W.tolist()
396
407
  W = [cp.array(item) for item in W]
397
408
 
409
+ elif model_type == 'PLAN':
410
+ W = cp.array(W)
411
+
398
412
  return W, None, test_acc, activations, scaler_params, None, model_type, WeightType, WeightFormat, device_version, df, activation_potentiation
399
413
 
400
414
 
@@ -472,9 +486,8 @@ def predict_from_storage(Input, model_name, model_path='', dtype=cp.float32):
472
486
 
473
487
  return result
474
488
 
475
- except:
476
- print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: predict_model_ssd." + Style.RESET_ALL)
477
- sys.exit(),
489
+ except Exception as e:
490
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred in predict_from_storage {e}" + Style.RESET_ALL) from e
478
491
 
479
492
 
480
493
 
@@ -505,9 +518,8 @@ def reverse_predict_from_storage(output, model_name, model_path='', dtype=cp.flo
505
518
  try:
506
519
  Input = W.T @ output
507
520
  return Input
508
- except:
509
- print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: reverse_predict_model_ssd." + Style.RESET_ALL)
510
- sys.exit()
521
+ except Exception as e:
522
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred {e}" + Style.RESET_ALL) from e
511
523
 
512
524
 
513
525
  def predict_from_memory(Input, W, scaler_params=None, activations=['linear'], activation_potentiation=None, model_type='PLAN'):
@@ -536,45 +548,52 @@ def predict_from_memory(Input, W, scaler_params=None, activations=['linear'], ac
536
548
  from .data_ops import standard_scaler
537
549
  from .activation_functions import apply_activation
538
550
 
539
- if isinstance(activations, str):
540
- activations = [activations]
541
- elif isinstance(activations, list):
542
- activations = [item if isinstance(item, list) or isinstance(item, str) else [item] for item in activations]
551
+ if model_type != 'PLAN' and model_type != 'MLP' and model_type != 'PTNN': raise ValueError("model_type parameter must be 'PLAN', 'MLP' or 'PTNN'.")
543
552
 
544
- Input = standard_scaler(None, Input, scaler_params)
553
+ try:
545
554
 
546
- if model_type == 'MLP':
547
- layer = Input
548
- for i in range(len(W)):
549
- if i != len(W) - 1 and i != 0: layer = apply_activation(layer, activations[i])
555
+ Input = standard_scaler(None, Input, scaler_params)
556
+
557
+ if isinstance(activations, str):
558
+ activations = [activations]
559
+ elif isinstance(activations, list):
560
+ activations = [item if isinstance(item, list) or isinstance(item, str) else [item] for item in activations]
550
561
 
551
- layer = layer @ W[i].T
562
+ if model_type == 'MLP':
563
+ layer = Input
564
+ for i in range(len(W)):
565
+ if i != len(W) - 1 and i != 0: layer = apply_activation(layer, activations[i])
552
566
 
553
- result = layer
567
+ layer = layer @ W[i].T
554
568
 
555
- if model_type == 'PLAN':
569
+ result = layer
556
570
 
557
- Input = apply_activation(Input, activations)
558
- result = Input @ W.T
559
-
560
- if model_type == 'PTNN':
571
+ if model_type == 'PLAN':
561
572
 
562
- if isinstance(activation_potentiation, str):
563
- activation_potentiation = [activation_potentiation]
564
- elif isinstance(activation_potentiation, list):
565
- activation_potentiation = [item if isinstance(item, list) or isinstance(item, str) else [item] for item in activation_potentiation]
573
+ Input = apply_activation(Input, activations)
574
+ result = Input @ W.T
575
+
576
+ if model_type == 'PTNN':
577
+
578
+ if isinstance(activation_potentiation, str):
579
+ activation_potentiation = [activation_potentiation]
580
+ elif isinstance(activation_potentiation, list):
581
+ activation_potentiation = [item if isinstance(item, list) or isinstance(item, str) else [item] for item in activation_potentiation]
566
582
 
567
- Input = apply_activation(Input, activation_potentiation)
568
- layer = Input @ W[0].T
583
+ Input = apply_activation(Input, activation_potentiation)
584
+ layer = Input @ W[0].T
569
585
 
570
- for i in range(1, len(W)):
571
- if i != len(W) - 1: layer = apply_activation(layer, activations[i])
586
+ for i in range(1, len(W)):
587
+ if i != len(W) - 1: layer = apply_activation(layer, activations[i])
572
588
 
573
- layer = layer @ W[i].T
589
+ layer = layer @ W[i].T
574
590
 
575
- result = layer
591
+ result = layer
576
592
 
577
- return result
593
+ return result
594
+
595
+ except Exception as e:
596
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred in predict_from_memory {e}" + Style.RESET_ALL) from e
578
597
 
579
598
 
580
599
 
@@ -601,9 +620,8 @@ def reverse_predict_from_memory(output, W, dtype=cp.float32):
601
620
  Input = W.T @ output
602
621
  return Input
603
622
 
604
- except:
605
- print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: reverse_predict_model_ram." + Style.RESET_ALL)
606
- sys.exit()
623
+ except Exception as e:
624
+ raise RuntimeError(Fore.RED + f"ERROR: An error occurred {e}" + Style.RESET_ALL) from e
607
625
 
608
626
 
609
627
  def get_weights():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 5.35
3
+ Version: 5.37
4
4
  Summary: PyereualJetwork is a GPU-accelerated machine learning library in Python for professionals and researchers. It features PLAN, MLP, Deep Learning training, and ENE (Eugenic NeuroEvolution) for genetic optimization, applicable to genetic algorithms or Reinforcement Learning (RL). The library includes data pre-processing, visualizations, model saving/loading, prediction, evaluation, training, and detailed or simplified memory management.
5
5
  Author: Hasan Can Beydili
6
6
  Author-email: tchasancan@gmail.com
@@ -1,4 +1,4 @@
1
- pyerualjetwork/__init__.py,sha256=tzemMNwT26zguana1GNc5FlQlTKpoAjo6nrcXSoSspQ,2704
1
+ pyerualjetwork/__init__.py,sha256=mq2efXuCnoIrT6GPNSgA0XIN3F-3qITy3fxvKiVYZyg,2704
2
2
  pyerualjetwork/fitness_functions.py,sha256=D9JVCr9DFid_xXgBD4uCKxdW2k10MVDE5HZRSOK4Igg,1237
3
3
  pyerualjetwork/help.py,sha256=Nyi0gHAN9ZnO4wgQLeENt0n7tSCZ3hJmjaJ853eGjCE,831
4
4
  pyerualjetwork/issue_solver.py,sha256=3pZTGotS29sy3pIuGQoJFUePibtSzS-tNoU80T_Usgk,3131
@@ -6,11 +6,11 @@ pyerualjetwork/memory_ops.py,sha256=TUFh9SYWCKL6N-vNdWId_EwU313TuZomQCHOrltrD-4,
6
6
  pyerualjetwork/ui.py,sha256=JBTFYz5R24XwNKhA3GSW-oYAoiIBxAE3kFGXkvm5gqw,656
7
7
  pyerualjetwork/cpu/__init__.py,sha256=0yAYner_-v7SmT3P7JV2itU8xJUQdQpb40dhAMQiZkc,829
8
8
  pyerualjetwork/cpu/activation_functions.py,sha256=zZSoOQ452Ykp_RsHVxklxesJmmFgufyIB4F3WQjudEQ,6689
9
- pyerualjetwork/cpu/data_ops.py,sha256=5biKr7pqLbJOayHYgGdQV1K5GqKbcOvrbbuAyByuDC8,16154
9
+ pyerualjetwork/cpu/data_ops.py,sha256=SPsIcjU0JPHfsnEmGjD8q-yTlpgYk-KPOPJ44dfp-nU,16143
10
10
  pyerualjetwork/cpu/ene.py,sha256=7ZPR7NDhuXCFSucH0l-_vUTDILnQOH-Zxv83Yy5gLL8,44451
11
11
  pyerualjetwork/cpu/loss_functions.py,sha256=6PyBI232SQRGuFnG3LDGvnv_PUdWzT2_2mUODJiejGI,618
12
12
  pyerualjetwork/cpu/metrics.py,sha256=WhZ8iEqWehaygPRADUlhA5j_Qv3UwqV_eMxpyRVkeVs,6070
13
- pyerualjetwork/cpu/model_ops.py,sha256=sWsP_7Gfa8_DJ2X7AUrOkeXnz2Eej6573grQQ3CooXM,20295
13
+ pyerualjetwork/cpu/model_ops.py,sha256=1KNgjUeYCO_TsA5RtbNiuIiBJzq8-rL2dE6jxKqCBU0,21481
14
14
  pyerualjetwork/cpu/nn.py,sha256=AiL1q-pWr-tzTtQlzoKRnqHQVEvgrUPLUl6_RY02T5s,32032
15
15
  pyerualjetwork/cpu/visualizations.py,sha256=rOQsc-W8b71z7ovXSoF49lx4fmpvlaHLsyj9ejWnhnI,28164
16
16
  pyerualjetwork/cuda/__init__.py,sha256=NbqvAS4jlMdoFdXa5_hi5ukXQ5zAZR_5BQ4QAqtiKug,879
@@ -19,10 +19,10 @@ pyerualjetwork/cuda/data_ops.py,sha256=SiNodFNmWyTPY_KnKuAi9biPRdpTAYY3XM01bRSUP
19
19
  pyerualjetwork/cuda/ene.py,sha256=dwH5l7CQqj4kUbcj8vC9gIgEdjFfRN-jw-06ABN-TiU,44976
20
20
  pyerualjetwork/cuda/loss_functions.py,sha256=C93IZJcrOpT6HMK9x1O4AHJWXYTkN5WZiqdssPbvAPk,617
21
21
  pyerualjetwork/cuda/metrics.py,sha256=PjDBoRvr6va8vRvDIJJGBO4-I4uumrk3NCM1Vz4NJTo,5054
22
- pyerualjetwork/cuda/model_ops.py,sha256=iQPuxmthKxP2GTFLHJppxoU64C6mEpkDW-DsfwFGiuY,21020
22
+ pyerualjetwork/cuda/model_ops.py,sha256=KJXZ_sxt7JfgEh6jLObhbtmn7zcMn708xeEZthzcNrI,23080
23
23
  pyerualjetwork/cuda/nn.py,sha256=EDdiWNUdrEHZXQ9K7qM74Q7OpacAgWM5MsQC8YANlY4,33164
24
24
  pyerualjetwork/cuda/visualizations.py,sha256=9l5BhXqXoeopdhLvVGvjH1TKYZb9JdKOsSE2IYD02zs,28569
25
- pyerualjetwork-5.35.dist-info/METADATA,sha256=N_4aSa6MZC16yCH49yTSqOfDJUekrZ4etURXIw9v7xA,8020
26
- pyerualjetwork-5.35.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
27
- pyerualjetwork-5.35.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
28
- pyerualjetwork-5.35.dist-info/RECORD,,
25
+ pyerualjetwork-5.37.dist-info/METADATA,sha256=DxPEG53B8FA8rX7xYx_WlxA6_R1nKs2XLlgIBjUtRRc,8020
26
+ pyerualjetwork-5.37.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
27
+ pyerualjetwork-5.37.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
28
+ pyerualjetwork-5.37.dist-info/RECORD,,