pyerualjetwork 4.1.5__py3-none-any.whl → 4.1.6__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.
@@ -14,7 +14,8 @@ package_names = [
14
14
  'numpy==1.26.4',
15
15
  'matplotlib==3.9.0',
16
16
  'colorama==0.4.6',
17
- 'psutil==6.1.1'
17
+ 'psutil==6.1.1',
18
+ 'cupy-cuda12x==13.3.0'
18
19
  ]
19
20
 
20
21
  installed_packages = pkg_resources.working_set
@@ -47,8 +48,8 @@ for package_name in package_names:
47
48
 
48
49
  print(f"PyerualJetwork is ready to use with {err} errors")
49
50
 
50
- __version__ = "4.1.5"
51
- __update__ = "* Note: CUDA modules need cupy. Enter this command in your terminal: 'pip install cupy-cuda12x' or your cuda version.\n* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES\n* PyerualJetwork document: https://github.com/HCB06/Anaplan/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf\n* YouTube tutorials: https://www.youtube.com/@HasanCanBeydili"
51
+ __version__ = "4.1.6"
52
+ __update__ = "* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES\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"
52
53
 
53
54
  def print_version(__version__):
54
55
  print(f"PyerualJetwork Version {__version__}" + '\n')
@@ -37,7 +37,7 @@ def Softmax(
37
37
  Returns:
38
38
  (num): Transformed data after applying softmax function.
39
39
  """
40
-
40
+
41
41
  return cp.array(softmax(x.get()))
42
42
 
43
43
 
@@ -16,26 +16,10 @@ def encode_one_hot(y_train, y_test=None, summary=False):
16
16
  Returns:
17
17
  tuple: One-hot encoded y_train and (if given) y_test.
18
18
  """
19
- if len(y_train) < 256:
20
- if y_train.dtype != np.uint8:
21
- y_train = np.array(y_train, copy=False).astype(np.uint8, copy=False)
22
- elif len(y_train) <= 32767:
23
- if y_train.dtype != np.uint16:
24
- y_train = np.array(y_train, copy=False).astype(np.uint16, copy=False)
25
- else:
26
- if y_train.dtype != np.uint32:
27
- y_train = np.array(y_train, copy=False).astype(np.uint32, copy=False)
28
-
29
- if y_test is not None:
30
- if len(y_test) < 256:
31
- if y_test.dtype != np.uint8:
32
- y_test = np.array(y_test, copy=False).astype(np.uint8, copy=False)
33
- elif len(y_test) <= 32767:
34
- if y_test.dtype != np.uint16:
35
- y_test = np.array(y_test, copy=False).astype(np.uint16, copy=False)
36
- else:
37
- if y_test.dtype != np.uint32:
38
- y_test = np.array(y_test, copy=False).astype(np.uint32, copy=False)
19
+ from .memory_operations import optimize_labels
20
+
21
+ y_train = optimize_labels(y_train, one_hot_encoded=False, cuda=False)
22
+ y_test = optimize_labels(y_test, one_hot_encoded=False, cuda=False)
39
23
 
40
24
  classes = np.unique(y_train)
41
25
  class_count = len(classes)
@@ -47,12 +31,12 @@ def encode_one_hot(y_train, y_test=None, summary=False):
47
31
  for cls, idx in class_to_index.items():
48
32
  print(f" {idx}: {cls}")
49
33
 
50
- y_train_encoded = np.zeros((y_train.shape[0], class_count))
34
+ y_train_encoded = np.zeros((y_train.shape[0], class_count), dtype=y_train.dtype)
51
35
  for i, label in enumerate(y_train):
52
36
  y_train_encoded[i, class_to_index[label]] = 1
53
37
 
54
38
  if y_test is not None:
55
- y_test_encoded = np.zeros((y_test.shape[0], class_count))
39
+ y_test_encoded = np.zeros((y_test.shape[0], class_count), dtype=y_test.dtype)
56
40
  for i, label in enumerate(y_test):
57
41
  y_test_encoded[i, class_to_index[label]] = 1
58
42
  return y_train_encoded, y_test_encoded
@@ -90,16 +74,10 @@ def split(X, y, test_size, random_state=42, dtype=np.float32):
90
74
  Returns:
91
75
  tuple: x_train, x_test, y_train, y_test as ordered training and testing data subsets.
92
76
  """
93
- X = X.astype(dtype)
94
- if len(y) < 256:
95
- if y.dtype != np.uint8:
96
- y = np.array(y, copy=False).astype(np.uint8, copy=False)
97
- elif len(y) <= 32767:
98
- if y.dtype != np.uint16:
99
- y = np.array(y, copy=False).astype(np.uint16, copy=False)
100
- else:
101
- if y.dtype != np.uint32:
102
- y = np.array(y, copy=False).astype(np.uint32, copy=False)
77
+ from .memory_operations import transfer_to_cpu, optimize_labels
78
+
79
+ X = transfer_to_cpu(X, dtype=dtype)
80
+ y = optimize_labels(y, one_hot_encoded=False, cuda=False)
103
81
 
104
82
  num_samples = X.shape[0]
105
83
 
@@ -124,6 +102,8 @@ def split(X, y, test_size, random_state=42, dtype=np.float32):
124
102
  x_train, x_test = X[train_indices], X[test_indices]
125
103
  y_train, y_test = y[train_indices], y[test_indices]
126
104
 
105
+ del X, y
106
+
127
107
  return x_train, x_test, y_train, y_test
128
108
 
129
109
 
@@ -142,20 +122,11 @@ def manuel_balancer(x_train, y_train, target_samples_per_class, dtype=np.float32
142
122
  y_balanced -- Balanced class labels (one-hot encoded, NumPy array format)
143
123
  """
144
124
  from .ui import loading_bars
145
-
146
- bar_format = loading_bars()[0]
125
+ from .memory_operations import transfer_to_cpu
147
126
 
148
- x_train = np.array(x_train, copy=False).astype(dtype, copy=False)
149
- if len(y_train[0]) < 256:
150
- if y_train.dtype != np.uint8:
151
- y_train = np.array(y_train, copy=False).astype(np.uint8, copy=False)
152
- elif len(y_train[0]) <= 32767:
153
- if y_train.dtype != np.uint16:
154
- y_train = np.array(y_train, copy=False).astype(np.uint16, copy=False)
155
- else:
156
- if y_train.dtype != np.uint32:
157
- y_train = np.array(y_train, copy=False).astype(np.uint32, copy=False)
127
+ x_train = transfer_to_cpu(x_train, dtype=dtype)
158
128
 
129
+ bar_format = loading_bars()[0]
159
130
  classes = np.arange(y_train.shape[1])
160
131
  class_count = len(classes)
161
132
 
@@ -181,8 +152,8 @@ def manuel_balancer(x_train, y_train, target_samples_per_class, dtype=np.float32
181
152
  if num_samples < target_samples_per_class:
182
153
 
183
154
  samples_to_add = target_samples_per_class - num_samples
184
- additional_samples = np.zeros((samples_to_add, x_train.shape[1]))
185
- additional_labels = np.zeros((samples_to_add, y_train.shape[1]))
155
+ additional_samples = np.zeros((samples_to_add, x_train.shape[1]), dtype=x_train.dtype)
156
+ additional_labels = np.zeros((samples_to_add, y_train.shape[1]), dtype=y_train.dtype)
186
157
 
187
158
  for i in range(samples_to_add):
188
159
 
@@ -200,10 +171,12 @@ def manuel_balancer(x_train, y_train, target_samples_per_class, dtype=np.float32
200
171
  x_balanced.append(additional_samples)
201
172
  y_balanced.append(additional_labels)
202
173
 
203
- x_balanced = np.vstack(x_balanced)
204
- y_balanced = np.vstack(y_balanced)
174
+ x_balanced = np.vstack(x_balanced, dtype=x_train.dtype)
175
+ y_balanced = np.vstack(y_balanced, dtype=y_train.dtype)
176
+
177
+ del x_train, y_train
205
178
 
206
- return x_balanced.astype(dtype), y_balanced.astype(dtype)
179
+ return x_balanced, y_balanced
207
180
 
208
181
 
209
182
  def auto_balancer(x_train, y_train, dtype=np.float32):
@@ -220,20 +193,11 @@ def auto_balancer(x_train, y_train, dtype=np.float32):
220
193
  tuple: A tuple containing balanced input data and labels.
221
194
  """
222
195
  from .ui import loading_bars
223
-
224
- bar_format = loading_bars()[0]
196
+ from .memory_operations import transfer_to_cpu
225
197
 
226
- x_train = np.array(x_train, copy=False).astype(dtype, copy=False)
227
- if len(y_train[0]) < 256:
228
- if y_train.dtype != np.uint8:
229
- y_train = np.array(y_train, copy=False).astype(np.uint8, copy=False)
230
- elif len(y_train[0]) <= 32767:
231
- if y_train.dtype != np.uint16:
232
- y_train = np.array(y_train, copy=False).astype(np.uint16, copy=False)
233
- else:
234
- if y_train.dtype != np.uint32:
235
- y_train = np.array(y_train, copy=False).astype(np.uint32, copy=False)
198
+ x_train = transfer_to_cpu(x_train, dtype=dtype)
236
199
 
200
+ bar_format = loading_bars()[0]
237
201
  classes = np.arange(y_train.shape[1])
238
202
  class_count = len(classes)
239
203
 
@@ -271,10 +235,15 @@ def auto_balancer(x_train, y_train, dtype=np.float32):
271
235
  print(Fore.RED + "ERROR: Inputs and labels must be same length check parameters")
272
236
  sys.exit()
273
237
 
274
- return BalancedInputs.astype(dtype, copy=False), BalancedLabels.astype(dtype, copy=False)
238
+ BalancedInputs = BalancedInputs.astype(dtype, copy=False)
239
+ BalancedLabels = BalancedLabels.astype(dtype=y_train.dtype, copy=False)
275
240
 
241
+ del x_train, y_train
276
242
 
277
- def synthetic_augmentation(x_train, y_train, dtype=np.float32):
243
+ return BalancedInputs, BalancedLabels
244
+
245
+
246
+ def synthetic_augmentation(x, y, dtype=np.float32):
278
247
  """
279
248
  Generates synthetic examples to balance classes with fewer examples.
280
249
 
@@ -288,24 +257,12 @@ def synthetic_augmentation(x_train, y_train, dtype=np.float32):
288
257
  y_balanced -- Balanced class labels (one-hot encoded, array format)
289
258
  """
290
259
  from .ui import loading_bars
291
-
292
- bar_format = loading_bars()[0]
260
+ from .memory_operations import transfer_to_cpu
293
261
 
294
- x_train = x_train.astype(dtype)
295
- if len(y_train[0]) < 256:
296
- if y_train.dtype != np.uint8:
297
- y_train = np.array(y_train, copy=False).astype(np.uint8, copy=False)
298
- elif len(y_train[0]) <= 32767:
299
- if y_train.dtype != np.uint16:
300
- y_train = np.array(y_train, copy=False).astype(np.uint16, copy=False)
301
- else:
302
- if y_train.dtype != np.uint32:
303
- y_train = np.array(y_train, copy=False).astype(np.uint32, copy=False)
304
-
305
- x = x_train
306
- y = y_train
262
+ x = transfer_to_cpu(x, dtype=dtype)
307
263
 
308
- classes = np.arange(y_train.shape[1])
264
+ bar_format = loading_bars()[0]
265
+ classes = np.arange(y.shape[1])
309
266
  class_count = len(classes)
310
267
 
311
268
  class_distribution = {i: 0 for i in range(class_count)}
@@ -340,8 +297,12 @@ def synthetic_augmentation(x_train, y_train, dtype=np.float32):
340
297
 
341
298
  num_samples += 1
342
299
 
300
+ x_balanced = np.array(x_balanced).astype(dtype, copy=False)
301
+ y_balanced = np.array(y_balanced).astype(dtype=y.dtype, copy=False)
302
+
303
+ del x, y
343
304
 
344
- return np.array(x_balanced).astype(dtype, copy=False), np.array(y_balanced).astype(dtype, copy=False)
305
+ return x_balanced, y_balanced
345
306
 
346
307
 
347
308
  def standard_scaler(x_train=None, x_test=None, scaler_params=None, dtype=np.float32):
@@ -17,29 +17,13 @@ def encode_one_hot(y_train, y_test=None, summary=False):
17
17
  tuple: One-hot encoded y_train and (if given) y_test.
18
18
  """
19
19
 
20
- if len(y_train) < 256:
21
- if y_train.dtype != cp.uint8:
22
- y_train = cp.array(y_train, copy=False).astype(cp.uint8, copy=False)
23
- elif len(y_train) <= 32767:
24
- if y_train.dtype != cp.uint16:
25
- y_train = cp.array(y_train, copy=False).astype(cp.uint16, copy=False)
26
- else:
27
- if y_train.dtype != cp.uint32:
28
- y_train = cp.array(y_train, copy=False).astype(cp.uint32, copy=False)
29
-
30
- if y_test is not None:
31
- if len(y_test) < 256:
32
- if y_test.dtype != cp.uint8:
33
- y_test = cp.array(y_test, copy=False).astype(cp.uint8, copy=False)
34
- elif len(y_test) <= 32767:
35
- if y_test.dtype != cp.uint16:
36
- y_test = cp.array(y_test, copy=False).astype(cp.uint16, copy=False)
37
- else:
38
- if y_test.dtype != cp.uint32:
39
- y_test = cp.array(y_test, copy=False).astype(cp.uint32, copy=False)
20
+ from .memory_operations import optimize_labels, transfer_to_cpu
21
+
22
+ y_train = optimize_labels(y_train, one_hot_encoded=False, cuda=True)
23
+ y_test = optimize_labels(y_test, one_hot_encoded=False, cuda=True)
40
24
 
41
- y_train = y_train.get()
42
- y_test = y_test.get()
25
+ y_train = transfer_to_cpu(y_train,dtype=y_train.dtype)
26
+ y_test = transfer_to_cpu(y_test,dtype=y_test.dtype)
43
27
 
44
28
  classes = np.unique(y_train)
45
29
  class_count = len(classes)
@@ -51,17 +35,17 @@ def encode_one_hot(y_train, y_test=None, summary=False):
51
35
  for cls, idx in class_to_index.items():
52
36
  print(f" {idx}: {cls}")
53
37
 
54
- y_train_encoded = np.zeros((y_train.shape[0], class_count))
38
+ y_train_encoded = np.zeros((y_train.shape[0], class_count), dtype=y_train.dtype)
55
39
  for i, label in enumerate(y_train):
56
40
  y_train_encoded[i, class_to_index[label]] = 1
57
41
 
58
42
  if y_test is not None:
59
- y_test_encoded = np.zeros((y_test.shape[0], class_count))
43
+ y_test_encoded = np.zeros((y_test.shape[0], class_count), dtype=y_test.dtype)
60
44
  for i, label in enumerate(y_test):
61
45
  y_test_encoded[i, class_to_index[label]] = 1
62
- return cp.array(y_train_encoded), cp.array(y_test_encoded)
46
+ return cp.array(y_train_encoded, dtype=y_train.dtype), cp.array(y_test_encoded, dtype=y_test.dtype)
63
47
 
64
- return cp.array(y_train_encoded)
48
+ return cp.array(y_train_encoded, dtype=y_train.dtype)
65
49
 
66
50
 
67
51
  def decode_one_hot(encoded_data):
@@ -75,9 +59,9 @@ def decode_one_hot(encoded_data):
75
59
  cupy.ndarray: Decoded categorical labels with shape (n_samples,).
76
60
  """
77
61
 
78
- decoded_labels = cp.argmax(encoded_data, axis=1)
62
+ if encoded_data.ndim == 1: return cp.argmax(encoded_data)
63
+ else: return cp.argmax(encoded_data, axis=1)
79
64
 
80
- return decoded_labels
81
65
 
82
66
 
83
67
  def split(X, y, test_size, random_state=42, dtype=cp.float32, use_cpu=False):
@@ -94,17 +78,10 @@ def split(X, y, test_size, random_state=42, dtype=cp.float32, use_cpu=False):
94
78
  Returns:
95
79
  tuple: x_train, x_test, y_train, y_test as ordered training and testing data subsets.
96
80
  """
97
- X = cp.array(X, copy=False).astype(dtype, copy=False)
98
- if len(y) < 256:
99
- if y.dtype != cp.uint8:
100
- y = cp.array(y, copy=False).astype(cp.uint8, copy=False)
101
- elif len(y) <= 32767:
102
- if y.dtype != cp.uint16:
103
- y = cp.array(y, copy=False).astype(cp.uint16, copy=False)
104
- else:
105
- if y.dtype != cp.uint32:
106
- y = cp.array(y, copy=False).astype(cp.uint32, copy=False)
107
-
81
+ from .memory_operations import transfer_to_gpu, optimize_labels
82
+
83
+ X = transfer_to_gpu(X, dtype=dtype)
84
+ y = optimize_labels(y, one_hot_encoded=False, cuda=True)
108
85
 
109
86
  num_samples = X.shape[0]
110
87
 
@@ -134,11 +111,9 @@ def split(X, y, test_size, random_state=42, dtype=cp.float32, use_cpu=False):
134
111
 
135
112
  x_train, x_test = X[train_indices], X[test_indices]
136
113
  y_train, y_test = y[train_indices], y[test_indices]
137
-
138
114
  del X
139
115
  del y
140
- cp.get_default_memory_pool.free_all_blocks()
141
-
116
+ cp.cuda.MemoryPool().free_all_blocks()
142
117
  return x_train, x_test, y_train, y_test
143
118
 
144
119
 
@@ -163,21 +138,11 @@ def manuel_balancer(x_train, y_train, target_samples_per_class, dtype=cp.float32
163
138
  y_balanced -- Balanced class labels (one-hot encoded, cupy array format)
164
139
  """
165
140
  from .ui import loading_bars
166
-
167
- bar_format = loading_bars()[0]
141
+ from .memory_operations import transfer_to_gpu
168
142
 
169
- x_train = cp.array(x_train, copy=False).astype(dtype, copy=False)
170
-
171
- if len(y_train[0]) < 256:
172
- if y_train.dtype != cp.uint8:
173
- y_train = cp.array(y_train, copy=False).astype(cp.uint8, copy=False)
174
- elif len(y_train[0]) <= 32767:
175
- if y_train.dtype != cp.uint16:
176
- y_train = cp.array(y_train, copy=False).astype(cp.uint16, copy=False)
177
- else:
178
- if y_train.dtype != cp.uint32:
179
- y_train = cp.array(y_train, copy=False).astype(cp.uint32, copy=False)
180
-
143
+ bar_format = loading_bars()[0]
144
+ x_train = transfer_to_gpu(x_train, dtype=dtype)
145
+ y_train = transfer_to_gpu(y_train, dtype=y_train.dtype)
181
146
 
182
147
  classes = cp.arange(y_train.shape[1])
183
148
  class_count = len(classes)
@@ -209,8 +174,8 @@ def manuel_balancer(x_train, y_train, target_samples_per_class, dtype=cp.float32
209
174
  if num_samples < target_samples_per_class:
210
175
 
211
176
  samples_to_add = target_samples_per_class - num_samples
212
- additional_samples = cp.zeros((samples_to_add, x_train.shape[1]))
213
- additional_labels = cp.zeros((samples_to_add, y_train.shape[1]))
177
+ additional_samples = cp.zeros((samples_to_add, x_train.shape[1]), dtype=x_train.dtype)
178
+ additional_labels = cp.zeros((samples_to_add, y_train.shape[1]), dtype=y_train.dtype)
214
179
 
215
180
  for i in range(samples_to_add):
216
181
 
@@ -234,8 +199,11 @@ def manuel_balancer(x_train, y_train, target_samples_per_class, dtype=cp.float32
234
199
  x_balanced.append(additional_samples)
235
200
  y_balanced.append(additional_labels)
236
201
 
237
- x_balanced = cp.vstack(x_balanced)
238
- y_balanced = cp.vstack(y_balanced)
202
+ x_balanced = cp.vstack(x_balanced, dtype=x_train.dtype)
203
+ y_balanced = cp.vstack(y_balanced, dtype=y_train.dtype)
204
+
205
+ del x_train, y_train
206
+ cp.cuda.MemoryPool().free_all_blocks()
239
207
 
240
208
  return x_balanced, y_balanced
241
209
 
@@ -248,7 +216,7 @@ def auto_balancer(x_train, y_train, dtype=cp.float32, use_cpu=False):
248
216
  Arguments:
249
217
  x_train (list): Input data for training.
250
218
 
251
- y_train (list): Labels corresponding to the input data.
219
+ y_train (list): Labels corresponding to the input data. (one-hot encoded)
252
220
 
253
221
  dtype (cupy.dtype): Data type for the arrays. np.float32 by default. Example: cp.float64 or cp.float16. [fp32 for balanced devices, fp64 for strong devices, fp16 for weak devices: not reccomended!] (optional)
254
222
 
@@ -257,26 +225,18 @@ def auto_balancer(x_train, y_train, dtype=cp.float32, use_cpu=False):
257
225
  tuple: A tuple containing balanced input data and labels.
258
226
  """
259
227
  from .ui import loading_bars
260
-
261
- x_train = cp.array(x_train, copy=False).astype(dtype, copy=False)
262
-
263
- if len(y_train[0]) < 256:
264
- if y_train.dtype != cp.uint8:
265
- y_train = cp.array(y_train, copy=False).astype(cp.uint8, copy=False)
266
- elif len(y_train[0]) <= 32767:
267
- if y_train.dtype != cp.uint16:
268
- y_train = cp.array(y_train, copy=False).astype(cp.uint16, copy=False)
269
- else:
270
- if y_train.dtype != cp.uint32:
271
- y_train = cp.array(y_train, copy=False).astype(cp.uint32, copy=False)
228
+ from .memory_operations import transfer_to_gpu
229
+
230
+ x_train = transfer_to_gpu(x_train, dtype=dtype)
231
+ y_train = transfer_to_gpu(y_train, dtype=y_train.dtype)
272
232
 
273
233
  bar_format = loading_bars()[0]
274
234
 
275
- classes = cp.arange(y_train.shape[1])
235
+ classes = cp.arange(y_train.shape[1], dtype=y_train.dtype)
276
236
  class_count = len(classes)
277
237
 
278
238
 
279
- ClassIndices = {i: cp.where(cp.array(y_train)[:, i] == 1)[
239
+ ClassIndices = {i: cp.where(y_train[:, i] == 1)[
280
240
  0] for i in range(class_count)}
281
241
  classes = [len(ClassIndices[i]) for i in range(class_count)]
282
242
 
@@ -313,8 +273,9 @@ def auto_balancer(x_train, y_train, dtype=cp.float32, use_cpu=False):
313
273
 
314
274
  print(Fore.GREEN + "Data Succesfully Balanced from: " + str(len(x_train)
315
275
  ) + " to: " + str(len(BalancedInputs)) + ". from: auto_balancer " + Style.RESET_ALL)
276
+ del x_train, y_train
277
+ cp.cuda.MemoryPool().free_all_blocks()
316
278
 
317
-
318
279
  return BalancedInputs, BalancedLabels
319
280
 
320
281
 
@@ -336,23 +297,13 @@ def synthetic_augmentation(x_train, y_train, dtype=cp.float32, use_cpu=False):
336
297
  y_train_balanced -- Balanced class labels (one-hot encoded, cupy array format)
337
298
  """
338
299
  from .ui import loading_bars
339
-
300
+ from .memory_operations import transfer_to_gpu
301
+
302
+ x = transfer_to_gpu(x_train, dtype=dtype)
303
+ y = transfer_to_gpu(y_train, dtype=y_train.dtype)
304
+
340
305
  bar_format = loading_bars()[0]
341
306
 
342
- x = x_train.astype(dtype, copy=False)
343
-
344
- if len(y_train[0]) < 256:
345
- if y_train.dtype != cp.uint8:
346
- y_train = cp.array(y_train, copy=False).astype(cp.uint8, copy=False)
347
- elif len(y_train[0]) <= 32767:
348
- if y_train.dtype != cp.uint16:
349
- y_train = cp.array(y_train, copy=False).astype(cp.uint16, copy=False)
350
- else:
351
- if y_train.dtype != cp.uint32:
352
- y_train = cp.array(y_train, copy=False).astype(cp.uint32, copy=False)
353
-
354
- y = y_train
355
-
356
307
  classes = cp.arange(y_train.shape[1])
357
308
  class_count = len(classes)
358
309
  class_distribution = {i: 0 for i in range(class_count)}
@@ -394,6 +345,9 @@ def synthetic_augmentation(x_train, y_train, dtype=cp.float32, use_cpu=False):
394
345
  x_balanced = cp.array(x_balanced)
395
346
  y_balanced = cp.array(y_balanced)
396
347
 
348
+ del x_train, y_train, x, y
349
+ cp.cuda.MemoryPool().free_all_blocks()
350
+
397
351
  return x_balanced, y_balanced
398
352
 
399
353
  def standard_scaler(x_train=None, x_test=None, scaler_params=None, dtype=cp.float32):
@@ -462,7 +416,6 @@ def normalization(
462
416
  MaxAbs = cp.max(cp.abs(Input.astype(dtype, copy=False)))
463
417
  return (Input / MaxAbs)
464
418
 
465
-
466
419
  def find_closest_factors(a):
467
420
 
468
421
  root = int(math.sqrt(a))