pyerualjetwork 4.3.8.dev15__py3-none-any.whl → 4.3.9b0__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.
Files changed (39) hide show
  1. pyerualjetwork/__init__.py +1 -1
  2. pyerualjetwork/activation_functions.py +2 -2
  3. pyerualjetwork/activation_functions_cuda.py +63 -114
  4. pyerualjetwork/data_operations_cuda.py +1 -1
  5. pyerualjetwork/model_operations.py +14 -14
  6. pyerualjetwork/model_operations_cuda.py +16 -17
  7. pyerualjetwork/plan.py +87 -268
  8. pyerualjetwork/plan_cuda.py +82 -276
  9. pyerualjetwork/planeat.py +12 -44
  10. pyerualjetwork/planeat_cuda.py +9 -45
  11. pyerualjetwork/visualizations.py +29 -26
  12. pyerualjetwork/visualizations_cuda.py +19 -20
  13. {pyerualjetwork-4.3.8.dev15.dist-info → pyerualjetwork-4.3.9b0.dist-info}/METADATA +2 -19
  14. pyerualjetwork-4.3.9b0.dist-info/RECORD +24 -0
  15. pyerualjetwork-4.3.9b0.dist-info/top_level.txt +1 -0
  16. pyerualjetwork-4.3.8.dev15.dist-info/RECORD +0 -45
  17. pyerualjetwork-4.3.8.dev15.dist-info/top_level.txt +0 -2
  18. pyerualjetwork_afterburner/__init__.py +0 -11
  19. pyerualjetwork_afterburner/activation_functions.py +0 -290
  20. pyerualjetwork_afterburner/activation_functions_cuda.py +0 -289
  21. pyerualjetwork_afterburner/data_operations.py +0 -406
  22. pyerualjetwork_afterburner/data_operations_cuda.py +0 -461
  23. pyerualjetwork_afterburner/help.py +0 -17
  24. pyerualjetwork_afterburner/loss_functions.py +0 -21
  25. pyerualjetwork_afterburner/loss_functions_cuda.py +0 -21
  26. pyerualjetwork_afterburner/memory_operations.py +0 -298
  27. pyerualjetwork_afterburner/metrics.py +0 -190
  28. pyerualjetwork_afterburner/metrics_cuda.py +0 -163
  29. pyerualjetwork_afterburner/model_operations.py +0 -408
  30. pyerualjetwork_afterburner/model_operations_cuda.py +0 -420
  31. pyerualjetwork_afterburner/parallel.py +0 -118
  32. pyerualjetwork_afterburner/plan.py +0 -432
  33. pyerualjetwork_afterburner/plan_cuda.py +0 -441
  34. pyerualjetwork_afterburner/planeat.py +0 -793
  35. pyerualjetwork_afterburner/planeat_cuda.py +0 -752
  36. pyerualjetwork_afterburner/ui.py +0 -22
  37. pyerualjetwork_afterburner/visualizations.py +0 -823
  38. pyerualjetwork_afterburner/visualizations_cuda.py +0 -825
  39. {pyerualjetwork-4.3.8.dev15.dist-info → pyerualjetwork-4.3.9b0.dist-info}/WHEEL +0 -0
@@ -1,4 +1,4 @@
1
- __version__ = "4.3.8dev15"
1
+ __version__ = "4.3.9b0"
2
2
  __update__ = "* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES\n* PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main\n* PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf\n* YouTube tutorials: https://www.youtube.com/@HasanCanBeydili"
3
3
 
4
4
  def print_version(__version__):
@@ -217,8 +217,8 @@ def scaled_cubic(x, alpha=1.0):
217
217
 
218
218
  def sine_offset(x, beta=0.0):
219
219
  return np.sin(x + beta)
220
-
221
-
220
+
221
+
222
222
  def apply_activation(Input, activation_list):
223
223
  """
224
224
  Applies activation functions for inputs
@@ -217,124 +217,73 @@ def scaled_cubic(x, alpha=1.0):
217
217
  def sine_offset(x, beta=0.0):
218
218
  return cp.sin(x + beta)
219
219
 
220
-
221
- def safe_add(current_sum, new_value):
222
- try:
223
- return current_sum + new_value
224
- except OverflowError:
225
- return cp.array(current_sum) + cp.array(new_value)
226
220
 
227
221
  def apply_activation(Input, activation_list):
228
222
  """
229
- Applies a sequence of activation functions to the input.
230
-
231
- Args:
232
- Input (cupy.ndarray): The input to apply activations to.
233
- activation_list (list): A list of activation function names to apply.
234
-
235
- Returns:
236
- cupy.ndarray: The input after all activations have been applied.
237
- """
223
+ Applies activation functions for inputs
238
224
 
225
+ Args:
226
+ Input (cupy.ndarray):
227
+ activation_list (list):
228
+ """
239
229
  origin_input = cp.copy(Input)
230
+
231
+ activation_functions = {
232
+ 'sigmoid': Sigmoid,
233
+ 'swish': swish,
234
+ 'mod_circular': modular_circular_activation,
235
+ 'tanh_circular': tanh_circular_activation,
236
+ 'leaky_relu': leaky_relu,
237
+ 'relu': Relu,
238
+ 'softplus': softplus,
239
+ 'elu': elu,
240
+ 'gelu': gelu,
241
+ 'selu': selu,
242
+ 'tanh': tanh,
243
+ 'sinakt': sinakt,
244
+ 'p_squared': p_squared,
245
+ 'sglu': lambda x: sglu(x, alpha=1.0),
246
+ 'dlrelu': dlrelu,
247
+ 'exsig': exsig,
248
+ 'sin_plus': sin_plus,
249
+ 'acos': lambda x: acos(x, alpha=1.0, beta=0.0),
250
+ 'gla': lambda x: gla(x, alpha=1.0, mu=0.0),
251
+ 'srelu': srelu,
252
+ 'qelu': qelu,
253
+ 'isra': isra,
254
+ 'waveakt': waveakt,
255
+ 'arctan': arctan,
256
+ 'bent_identity': bent_identity,
257
+ 'sech': sech,
258
+ 'softsign': softsign,
259
+ 'pwl': pwl,
260
+ 'cubic': cubic,
261
+ 'gaussian': gaussian,
262
+ 'sine': sine,
263
+ 'tanh_square': tanh_square,
264
+ 'mod_sigmoid': mod_sigmoid,
265
+ 'linear': lambda x: x,
266
+ 'quartic': quartic,
267
+ 'square_quartic': square_quartic,
268
+ 'cubic_quadratic': cubic_quadratic,
269
+ 'exp_cubic': exp_cubic,
270
+ 'sine_square': sine_square,
271
+ 'logarithmic': logarithmic,
272
+ 'scaled_cubic': lambda x: scaled_cubic(x, 1.0),
273
+ 'sine_offset': lambda x: sine_offset(x, 1.0),
274
+ 'spiral': spiral_activation,
275
+ 'circular': circular_activation
276
+ }
277
+
278
+ try:
279
+
280
+ valid_mask = cp.array([act in activation_functions for act in activation_list])
281
+ valid_activations = cp.array(activation_list)[valid_mask]
282
+
283
+ activation_outputs = cp.array([activation_functions[act](origin_input) for act in valid_activations])
240
284
 
241
- for i in range(len(activation_list)):
242
- try:
243
- if activation_list[i] == 'sigmoid':
244
- Input = safe_add(Input, Sigmoid(origin_input))
245
- elif activation_list[i] == 'swish':
246
- Input = safe_add(Input, swish(origin_input))
247
- elif activation_list[i] == 'mod_circular':
248
- Input = safe_add(Input, modular_circular_activation(origin_input))
249
- elif activation_list[i] == 'tanh_circular':
250
- Input = safe_add(Input, tanh_circular_activation(origin_input))
251
- elif activation_list[i] == 'leaky_relu':
252
- Input = safe_add(Input, leaky_relu(origin_input))
253
- elif activation_list[i] == 'relu':
254
- Input = safe_add(Input, Relu(origin_input))
255
- elif activation_list[i] == 'softplus':
256
- Input = safe_add(Input, softplus(origin_input))
257
- elif activation_list[i] == 'elu':
258
- Input = safe_add(Input, elu(origin_input))
259
- elif activation_list[i] == 'gelu':
260
- Input = safe_add(Input, gelu(origin_input))
261
- elif activation_list[i] == 'selu':
262
- Input = safe_add(Input, selu(origin_input))
263
- elif activation_list[i] == 'tanh':
264
- Input = safe_add(Input, tanh(origin_input))
265
- elif activation_list[i] == 'sinakt':
266
- Input = safe_add(Input, sinakt(origin_input))
267
- elif activation_list[i] == 'p_squared':
268
- Input = safe_add(Input, p_squared(origin_input))
269
- elif activation_list[i] == 'sglu':
270
- Input = safe_add(Input, sglu(origin_input, alpha=1.0))
271
- elif activation_list[i] == 'dlrelu':
272
- Input = safe_add(Input, dlrelu(origin_input))
273
- elif activation_list[i] == 'exsig':
274
- Input = safe_add(Input, exsig(origin_input))
275
- elif activation_list[i] == 'sin_plus':
276
- Input = safe_add(Input, sin_plus(origin_input))
277
- elif activation_list[i] == 'acos':
278
- Input = safe_add(Input, acos(origin_input, alpha=1.0, beta=0.0))
279
- elif activation_list[i] == 'gla':
280
- Input = safe_add(Input, gla(origin_input, alpha=1.0, mu=0.0))
281
- elif activation_list[i] == 'srelu':
282
- Input = safe_add(Input, srelu(origin_input))
283
- elif activation_list[i] == 'qelu':
284
- Input = safe_add(Input, qelu(origin_input))
285
- elif activation_list[i] == 'isra':
286
- Input = safe_add(Input, isra(origin_input))
287
- elif activation_list[i] == 'waveakt':
288
- Input = safe_add(Input, waveakt(origin_input))
289
- elif activation_list[i] == 'arctan':
290
- Input = safe_add(Input, arctan(origin_input))
291
- elif activation_list[i] == 'bent_identity':
292
- Input = safe_add(Input, bent_identity(origin_input))
293
- elif activation_list[i] == 'sech':
294
- Input = safe_add(Input, sech(origin_input))
295
- elif activation_list[i] == 'softsign':
296
- Input = safe_add(Input, softsign(origin_input))
297
- elif activation_list[i] == 'pwl':
298
- Input = safe_add(Input, pwl(origin_input))
299
- elif activation_list[i] == 'cubic':
300
- Input = safe_add(Input, cubic(origin_input))
301
- elif activation_list[i] == 'gaussian':
302
- Input = safe_add(Input, gaussian(origin_input))
303
- elif activation_list[i] == 'sine':
304
- Input = safe_add(Input, sine(origin_input))
305
- elif activation_list[i] == 'tanh_square':
306
- Input = safe_add(Input, tanh_square(origin_input))
307
- elif activation_list[i] == 'mod_sigmoid':
308
- Input = safe_add(Input, mod_sigmoid(origin_input))
309
- elif activation_list[i] == 'linear':
310
- Input = safe_add(Input, origin_input)
311
- elif activation_list[i] == 'quartic':
312
- Input = safe_add(Input, quartic(origin_input))
313
- elif activation_list[i] == 'square_quartic':
314
- Input = safe_add(Input, square_quartic(origin_input))
315
- elif activation_list[i] == 'cubic_quadratic':
316
- Input = safe_add(Input, cubic_quadratic(origin_input))
317
- elif activation_list[i] == 'exp_cubic':
318
- Input = safe_add(Input, exp_cubic(origin_input))
319
- elif activation_list[i] == 'sine_square':
320
- Input = safe_add(Input, sine_square(origin_input))
321
- elif activation_list[i] == 'logarithmic':
322
- Input = safe_add(Input, logarithmic(origin_input))
323
- elif activation_list[i] == 'scaled_cubic':
324
- Input = safe_add(Input, scaled_cubic(origin_input, 1.0))
325
- elif activation_list[i] == 'sine_offset':
326
- Input = safe_add(Input, sine_offset(origin_input, 1.0))
327
- elif activation_list[i] == 'spiral':
328
- Input = safe_add(Input, spiral_activation(origin_input))
329
- elif activation_list[i] == 'circular':
330
- Input = safe_add(Input, circular_activation(origin_input))
285
+ return Input + cp.sum(activation_outputs, axis=0)
331
286
 
332
- except Exception as e:
333
- warnings.warn(f"Error in activation {activation_list[i]}: {str(e)}", RuntimeWarning)
334
- if not isinstance(Input, cp.ndarray):
335
- Input = cp.array(Input)
336
- if not isinstance(origin_input, cp.ndarray):
337
- origin_input = cp.array(origin_input)
338
- continue
339
-
340
- return Input
287
+ except Exception as e:
288
+ warnings.warn(f"Error in activation processing: {str(e)}", RuntimeWarning)
289
+ return Input
@@ -401,7 +401,7 @@ def standard_scaler(x_train=None, x_test=None, scaler_params=None, dtype=cp.floa
401
401
 
402
402
  return scaled_data # sample data scaled
403
403
 
404
-
404
+
405
405
  def normalization(
406
406
  Input, # num: Input data to be normalized.
407
407
  dtype=cp.float32
@@ -258,7 +258,7 @@ def predict_model_ssd(Input, model_name, model_path='', dtype=np.float32):
258
258
  ndarray: Output from the model.
259
259
  """
260
260
 
261
- from .plan import feed_forward
261
+ from .activation_functions import apply_activation
262
262
  from .data_operations import standard_scaler
263
263
 
264
264
  model = load_model(model_name, model_path)
@@ -269,12 +269,12 @@ def predict_model_ssd(Input, model_name, model_path='', dtype=np.float32):
269
269
 
270
270
  Input = standard_scaler(None, Input, scaler_params, dtype=dtype)
271
271
 
272
- neural_layer = Input
273
- neural_layer = np.array(neural_layer, copy=False)
274
- neural_layer = neural_layer.ravel()
272
+ Input = np.array(Input, dtype=dtype, copy=False)
273
+ Input = Input.ravel()
275
274
 
276
275
  try:
277
- neural_layer = feed_forward(neural_layer, np.copy(W.astype(dtype, copy=False)), is_training=False, Class='?', activation_potentiation=activation_potentiation)
276
+ Input = apply_activation(Input, activation_potentiation)
277
+ neural_layer = Input @ W.T
278
278
  return neural_layer
279
279
  except:
280
280
  print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: predict_model_ssd." + Style.RESET_ALL)
@@ -304,7 +304,7 @@ def reverse_predict_model_ssd(output, model_name, model_path='', dtype=np.float3
304
304
  W = model[get_weights()]
305
305
 
306
306
  try:
307
- Input = np.dot(output.astype(dtype, copy=False), np.copy(W.astype(dtype, copy=False)))
307
+ Input = W.T @ output
308
308
  return Input
309
309
  except:
310
310
  print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: reverse_predict_model_ssd." + Style.RESET_ALL)
@@ -334,18 +334,18 @@ def predict_model_ram(Input, W, scaler_params=None, activation_potentiation=['li
334
334
  ndarray: Output from the model.
335
335
  """
336
336
 
337
- from data_operations import standard_scaler
338
- from plan import feed_forward
337
+ from .data_operations import standard_scaler
338
+ from .activation_functions import apply_activation
339
339
 
340
340
  Input = standard_scaler(None, Input, scaler_params, dtype=dtype)
341
341
 
342
+ Input = np.array(Input, dtype=dtype, copy=False)
343
+ Input = Input.ravel()
344
+
342
345
  try:
343
346
 
344
- neural_layer = Input
345
- neural_layer = np.array(neural_layer, copy=False)
346
- neural_layer = neural_layer.ravel()
347
-
348
- neural_layer = feed_forward(neural_layer, np.copy(W.astype(dtype, copy=False)), is_training=False, Class='?', activation_potentiation=activation_potentiation)
347
+ Input = apply_activation(Input, activation_potentiation)
348
+ neural_layer = Input @ W.T
349
349
 
350
350
  return neural_layer
351
351
 
@@ -371,7 +371,7 @@ def reverse_predict_model_ram(output, W, dtype=np.float32):
371
371
  """
372
372
 
373
373
  try:
374
- Input = np.dot(output.astype(dtype, copy=False), np.copy(W.astype(dtype, copy=False)))
374
+ Input = W.T @ output
375
375
  return Input
376
376
 
377
377
  except:
@@ -263,10 +263,10 @@ def predict_model_ssd(Input, model_name, model_path='', dtype=cp.float32):
263
263
  Returns:
264
264
  ndarray: Output from the model.
265
265
  """
266
-
266
+
267
267
  Input = cp.array(Input, dtype=dtype, copy=False)
268
-
269
- from .plan_cuda import feed_forward
268
+
269
+ from .activation_functions_cuda import apply_activation
270
270
  from .data_operations_cuda import standard_scaler
271
271
 
272
272
  model = load_model(model_name, model_path)
@@ -277,13 +277,14 @@ def predict_model_ssd(Input, model_name, model_path='', dtype=cp.float32):
277
277
 
278
278
  Input = standard_scaler(None, Input, scaler_params)
279
279
 
280
- neural_layer = Input
281
- neural_layer = cp.array(neural_layer)
282
- neural_layer = neural_layer.ravel()
280
+ Input = cp.array(Input, dtype=dtype, copy=False)
281
+ Input = Input.ravel()
283
282
 
284
283
  try:
285
- neural_layer = feed_forward(neural_layer, cp.copy(W), is_training=False, Class='?', activation_potentiation=activation_potentiation)
284
+ Input = apply_activation(Input, activation_potentiation)
285
+ neural_layer = Input @ W.T
286
286
  return neural_layer
287
+
287
288
  except:
288
289
  print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: predict_model_ssd." + Style.RESET_ALL)
289
290
  sys.exit()
@@ -314,7 +315,7 @@ def reverse_predict_model_ssd(output, model_name, model_path='', dtype=cp.float3
314
315
  W = model[get_weights()]
315
316
 
316
317
  try:
317
- Input = cp.dot(output, cp.copy(W))
318
+ Input = W.T @ output
318
319
  return Input
319
320
  except:
320
321
  print(Fore.RED + "ERROR: Unexpected Output or wrong model parameters from: reverse_predict_model_ssd." + Style.RESET_ALL)
@@ -344,19 +345,17 @@ def predict_model_ram(Input, W, scaler_params=None, activation_potentiation=['li
344
345
  """
345
346
 
346
347
  from .data_operations_cuda import standard_scaler
347
- from .plan_cuda import feed_forward
348
+ from .activation_functions_cuda import apply_activation
348
349
 
349
- Input = cp.array(Input, dtype=dtype, copy=False)
350
-
351
350
  Input = standard_scaler(None, Input, scaler_params)
352
351
 
352
+ Input = cp.array(Input, dtype=dtype, copy=False)
353
+ Input = Input.ravel()
354
+
353
355
  try:
354
356
 
355
- neural_layer = Input
356
- neural_layer = cp.array(neural_layer)
357
- neural_layer = neural_layer.ravel()
358
-
359
- neural_layer = feed_forward(neural_layer, cp.copy(W), is_training=False, Class='?', activation_potentiation=activation_potentiation)
357
+ Input = apply_activation(Input, activation_potentiation)
358
+ neural_layer = Input @ W.T
360
359
 
361
360
  return neural_layer
362
361
 
@@ -384,7 +383,7 @@ def reverse_predict_model_ram(output, W, dtype=cp.float32):
384
383
  output = cp.array(output, dtype=dtype, copy=False)
385
384
 
386
385
  try:
387
- Input = cp.dot(output, cp.copy(W))
386
+ Input = W.T @ output
388
387
  return Input
389
388
 
390
389
  except: