pyerualjetwork 4.3.8.dev14__py3-none-any.whl → 4.3.9__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 (42) 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/fitness_functions.py +72 -0
  6. pyerualjetwork/fitness_functions_cuda.py +85 -0
  7. pyerualjetwork/model_operations.py +14 -14
  8. pyerualjetwork/model_operations_cuda.py +16 -17
  9. pyerualjetwork/plan.py +159 -382
  10. pyerualjetwork/plan_cuda.py +149 -387
  11. pyerualjetwork/planeat.py +24 -54
  12. pyerualjetwork/planeat_cuda.py +11 -47
  13. pyerualjetwork/visualizations.py +33 -30
  14. pyerualjetwork/visualizations_cuda.py +22 -24
  15. {pyerualjetwork-4.3.8.dev14.dist-info → pyerualjetwork-4.3.9.dist-info}/METADATA +3 -19
  16. pyerualjetwork-4.3.9.dist-info/RECORD +24 -0
  17. pyerualjetwork-4.3.9.dist-info/top_level.txt +1 -0
  18. pyerualjetwork/loss_functions.py +0 -21
  19. pyerualjetwork/loss_functions_cuda.py +0 -21
  20. pyerualjetwork-4.3.8.dev14.dist-info/RECORD +0 -44
  21. pyerualjetwork-4.3.8.dev14.dist-info/top_level.txt +0 -2
  22. pyerualjetwork_afterburner/__init__.py +0 -11
  23. pyerualjetwork_afterburner/activation_functions.py +0 -290
  24. pyerualjetwork_afterburner/activation_functions_cuda.py +0 -289
  25. pyerualjetwork_afterburner/data_operations.py +0 -406
  26. pyerualjetwork_afterburner/data_operations_cuda.py +0 -461
  27. pyerualjetwork_afterburner/help.py +0 -17
  28. pyerualjetwork_afterburner/loss_functions.py +0 -21
  29. pyerualjetwork_afterburner/loss_functions_cuda.py +0 -21
  30. pyerualjetwork_afterburner/memory_operations.py +0 -298
  31. pyerualjetwork_afterburner/metrics.py +0 -190
  32. pyerualjetwork_afterburner/metrics_cuda.py +0 -163
  33. pyerualjetwork_afterburner/model_operations.py +0 -408
  34. pyerualjetwork_afterburner/model_operations_cuda.py +0 -420
  35. pyerualjetwork_afterburner/plan.py +0 -432
  36. pyerualjetwork_afterburner/plan_cuda.py +0 -441
  37. pyerualjetwork_afterburner/planeat.py +0 -793
  38. pyerualjetwork_afterburner/planeat_cuda.py +0 -840
  39. pyerualjetwork_afterburner/ui.py +0 -22
  40. pyerualjetwork_afterburner/visualizations.py +0 -823
  41. pyerualjetwork_afterburner/visualizations_cuda.py +0 -825
  42. {pyerualjetwork-4.3.8.dev14.dist-info → pyerualjetwork-4.3.9.dist-info}/WHEEL +0 -0
@@ -1,4 +1,4 @@
1
- __version__ = "4.3.8dev14"
1
+ __version__ = "4.3.9"
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
@@ -0,0 +1,72 @@
1
+ import numpy as np
2
+ from scipy.spatial.distance import pdist
3
+
4
+ def diversity_score(population):
5
+ """
6
+ Calculates the diversity score of a population based on the
7
+ Euclidean distances between individuals in the population.
8
+
9
+ :param population: That calculates the diversity score of a population based on the Euclidean distances between
10
+ individuals in the population
11
+ :return: The function returns the diversity score,
12
+ which is a measure of how spread out or diverse the population is in terms of their characteristics.
13
+ """
14
+ if len(population) < 2:
15
+ return 0
16
+
17
+ population = np.nan_to_num(population, nan=0.0)
18
+
19
+ distances = pdist(population, metric='euclidean')
20
+ distances = np.maximum(distances, 1e-10)
21
+
22
+ avg_distance = np.mean(distances)
23
+ if population.shape[1] == 0:
24
+ return 0
25
+
26
+ max_possible_distance = np.sqrt(population.shape[1])
27
+ max_possible_distance = max(max_possible_distance, 1e-10)
28
+
29
+ diversity = avg_distance / max_possible_distance
30
+ return diversity
31
+
32
+ def multi_head_fitness(y_true, y_pred, diversity_score, accuracy, alpha=2, beta=1.5, lambda_div=0.05):
33
+ """
34
+ The function calculates a fitness score based on accuracy, margin loss, and diversity score using
35
+ specified parameters.
36
+
37
+ @param y_true The `y_true` parameter represents the true labels of the data points. It is an array
38
+ or list containing the actual labels of the data points.
39
+ @param y_pred The `y_pred` parameter in the `multi_head_fitness` function represents the
40
+ predicted values for a given dataset. It is a NumPy array containing the predicted values for each
41
+ sample in the dataset.
42
+ @param diversity_score The `diversity_score` parameter in the `multi_head_fitness` function
43
+ represents a measure of diversity in the predictions. It is used as a factor in calculating the
44
+ fitness of the model. The function combines accuracy, margin loss, and diversity score to evaluate
45
+ the overall performance of the model
46
+ @param accuracy Accuracy is a measure of the correct predictions made by a model. It is typically
47
+ calculated as the number of correct predictions divided by the total number of predictions. In the
48
+ context of the `multi_head_fitness` function, the accuracy parameter represents the accuracy
49
+ of the model's predictions.
50
+ @param alpha Alpha is a parameter that controls the impact of accuracy on the overall fitness score
51
+ in the multi_head_fitness function. It is used as an exponent to raise the accuracy value
52
+ to, influencing its contribution to the fitness calculation.
53
+ @param beta The `beta` parameter in the `multi_head_fitness` function is used as an exponent
54
+ in the fitness calculation formula. It controls the impact of the margin loss term on the overall
55
+ fitness value. A higher value of `beta` will amplify the effect of the margin loss term, making it
56
+ @param lambda_div The `lambda_div` parameter in the `multi_head_fitness` function represents
57
+ the weight given to the diversity score in calculating the fitness value. It is a hyperparameter
58
+ that controls the impact of diversity score on the overall fitness calculation. A higher value of
59
+ `lambda_div` will increase the importance
60
+ @return The function `multi_head_fitness` returns the fitness value calculated based on the
61
+ input parameters `y_true`, `y_pred`, `diversity_score`, `accuracy`, and optional parameters `alpha`,
62
+ `beta`, and `lambda_div`. The fitness value is computed using a formula that combines accuracy,
63
+ margin loss, and diversity score with specified weights and coefficients.
64
+ """
65
+ incorrect = y_true != y_pred
66
+ margin_loss = np.abs(y_true[incorrect] - y_pred[incorrect]).mean() if np.any(incorrect) else 0
67
+
68
+ margin_loss = np.nan_to_num(margin_loss, nan=0.0)
69
+ accuracy = max(accuracy, 1e-10)
70
+
71
+ fitness = (accuracy ** alpha) * ((1 - margin_loss) ** beta) * (1 + lambda_div * diversity_score)
72
+ return fitness
@@ -0,0 +1,85 @@
1
+ import cupy as cp
2
+
3
+ def cupy_pairwise_distances(X):
4
+ """
5
+ Pairwise Euclidean distances
6
+ """
7
+ r = cp.sum(X * X, 1)
8
+ r = r.reshape(-1, 1)
9
+
10
+ distances = cp.maximum(r - 2 * cp.dot(X, X.T) + r.T, 0.0)
11
+
12
+ triu_indices = cp.triu_indices(distances.shape[0], k=1)
13
+ return cp.sqrt(distances[triu_indices])
14
+
15
+
16
+ def diversity_score(population):
17
+ """
18
+ Calculates the diversity score of a population based on the
19
+ Euclidean distances between individuals in the population.
20
+
21
+ :param population: That calculates the diversity score of a population based on the Euclidean distances between
22
+ individuals in the population
23
+ :return: The function returns the diversity score,
24
+ which is a measure of how spread out or diverse the population is in terms of their characteristics.
25
+ """
26
+ if len(population) < 2:
27
+ return 0
28
+
29
+ population = cp.nan_to_num(population, nan=0.0)
30
+
31
+ distances = cupy_pairwise_distances(population)
32
+ distances = cp.maximum(distances, 1e-10)
33
+
34
+ avg_distance = cp.mean(distances)
35
+ if population.shape[1] == 0:
36
+ return 0
37
+
38
+ max_possible_distance = cp.sqrt(population.shape[1])
39
+ max_possible_distance = float(max(max_possible_distance, 1e-10))
40
+
41
+ diversity = float(avg_distance / max_possible_distance)
42
+ return diversity
43
+
44
+
45
+ def multi_head_fitness(y_true, y_pred, diversity_score, accuracy, alpha=2, beta=1.5, lambda_div=0.05):
46
+ """
47
+ The function calculates a fitness score based on accuracy, margin loss, and diversity score using
48
+ specified parameters.
49
+
50
+ @param y_true The `y_true` parameter represents the true labels of the data points. It is an array
51
+ or list containing the actual labels of the data points.
52
+ @param y_pred The `y_pred` parameter in the `multi_head_fitness` function represents the
53
+ predicted values for a given dataset. It is a NumPy array containing the predicted values for each
54
+ sample in the dataset.
55
+ @param diversity_score The `diversity_score` parameter in the `multi_head_fitness` function
56
+ represents a measure of diversity in the predictions. It is used as a factor in calculating the
57
+ fitness of the model. The function combines accuracy, margin loss, and diversity score to evaluate
58
+ the overall performance of the model
59
+ @param accuracy Accuracy is a measure of the correct predictions made by a model. It is typically
60
+ calculated as the number of correct predictions divided by the total number of predictions. In the
61
+ context of the `multi_head_fitness` function, the accuracy parameter represents the accuracy
62
+ of the model's predictions.
63
+ @param alpha Alpha is a parameter that controls the impact of accuracy on the overall fitness score
64
+ in the multi_head_fitness function. It is used as an exponent to raise the accuracy value
65
+ to, influencing its contribution to the fitness calculation.
66
+ @param beta The `beta` parameter in the `multi_head_fitness` function is used as an exponent
67
+ in the fitness calculation formula. It controls the impact of the margin loss term on the overall
68
+ fitness value. A higher value of `beta` will amplify the effect of the margin loss term, making it
69
+ @param lambda_div The `lambda_div` parameter in the `multi_head_fitness` function represents
70
+ the weight given to the diversity score in calculating the fitness value. It is a hyperparameter
71
+ that controls the impact of diversity score on the overall fitness calculation. A higher value of
72
+ `lambda_div` will increase the importance
73
+ @return The function `multi_head_fitness` returns the fitness value calculated based on the
74
+ icput parameters `y_true`, `y_pred`, `diversity_score`, `accuracy`, and optional parameters `alpha`,
75
+ `beta`, and `lambda_div`. The fitness value is computed using a formula that combines accuracy,
76
+ margin loss, and diversity score with specified weights and coefficients.
77
+ """
78
+ incorrect = y_true != y_pred
79
+ margin_loss = cp.abs(y_true[incorrect] - y_pred[incorrect]).mean() if cp.any(incorrect) else 0
80
+
81
+ margin_loss = cp.nan_to_num(margin_loss, nan=0.0)
82
+ accuracy = max(accuracy, 1e-10)
83
+
84
+ fitness = (accuracy ** alpha) * ((1 - margin_loss) ** beta) * (1 + lambda_div * diversity_score)
85
+ return fitness
@@ -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: