pyerualjetwork 4.6.5__py3-none-any.whl → 4.6.7__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.
@@ -1,4 +1,4 @@
1
- __version__ = "4.6.5"
1
+ __version__ = "4.6.7"
2
2
  __update__ = """* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES
3
3
  * PyerualJetwork Homepage: https://github.com/HCB06/PyerualJetwork/tree/main
4
4
  * PyerualJetwork document: https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf
@@ -142,64 +142,56 @@ def save_model(model_name,
142
142
  df = pd.DataFrame(data)
143
143
  df.to_pickle(model_path + model_name + '.pkl')
144
144
 
145
- if isinstance(W, list): max_file = len(W)
146
- else: max_file = 1
147
-
148
- for i in range(max_file):
149
-
150
- if max_file > 1: weight = W[i]
151
- else: weight = W
145
+ try:
152
146
 
153
- try:
147
+ if weights_type == 'txt' and weights_format == 'f':
154
148
 
155
- if weights_type == 'txt' and weights_format == 'f':
149
+ np.savetxt(model_path + model_name + f'_weights.txt', W, fmt='%f')
156
150
 
157
- np.savetxt(model_path + model_name + f'weights{i}.txt', weight, fmt='%f')
151
+ if weights_type == 'txt' and weights_format == 'raw':
158
152
 
159
- if weights_type == 'txt' and weights_format == 'raw':
153
+ np.savetxt(model_path + model_name + f'_weights.txt', W)
160
154
 
161
- np.savetxt(model_path + model_name + f'weights{i}.txt', weight)
155
+ ###
162
156
 
163
- ###
157
+
158
+ if weights_type == 'pkl' and weights_format == 'f':
164
159
 
165
-
166
- if weights_type == 'pkl' and weights_format == 'f':
160
+ with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
161
+ pickle.dump(W.astype(float), f)
167
162
 
168
- with open(model_path + model_name + f'weights{i}.pkl', 'wb') as f:
169
- pickle.dump(weight.astype(float), f)
163
+ if weights_type == 'pkl' and weights_format =='raw':
164
+
165
+ with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
166
+ pickle.dump(W, f)
170
167
 
171
- if weights_type == 'pkl' and weights_format =='raw':
172
-
173
- with open(model_path + model_name + f'weights{i}.pkl', 'wb') as f:
174
- pickle.dump(weight, f)
168
+ ###
175
169
 
176
- ###
170
+ if weights_type == 'npy' and weights_format == 'f':
177
171
 
178
- if weights_type == 'npy' and weights_format == 'f':
172
+ np.save(model_path + model_name + f'_weights.npy', W, W.astype(float))
179
173
 
180
- np.save(model_path + model_name + f'weights{i}.npy', weight, weight.astype(float))
174
+ if weights_type == 'npy' and weights_format == 'raw':
181
175
 
182
- if weights_type == 'npy' and weights_format == 'raw':
176
+ np.save(model_path + model_name + f'_weights.npy', W)
183
177
 
184
- np.save(model_path + model_name + f'weights{i}.npy', weight)
178
+ ###
185
179
 
186
- ###
180
+ if weights_type == 'mat' and weights_format == 'f':
187
181
 
188
- if weights_type == 'mat' and weights_format == 'f':
182
+ w = {'w': W.astype(float)}
183
+ io.savemat(model_path + model_name + f'_weights.mat', w)
189
184
 
190
- w = {'w': weight.astype(float)}
191
- io.savemat(model_path + model_name + f'weights{i}.mat', w)
185
+ if weights_type == 'mat' and weights_format == 'raw':
186
+
187
+ w = {'w': W}
188
+ io.savemat(model_path + model_name + f'_weights.mat', w)
192
189
 
193
- if weights_type == 'mat' and weights_format == 'raw':
194
-
195
- w = {'w': weight}
196
- io.savemat(model_path + model_name + f'weights{i}.mat', w)
190
+ except:
197
191
 
198
- except:
192
+ 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)
193
+ sys.exit()
199
194
 
200
- print(Fore.RED + "ERROR: Model Weights not saved. Check the Weight parameters. SaveFilePath expl: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: save_model" + Style.RESET_ALL)
201
- sys.exit()
202
-
203
195
  if show_info:
204
196
  print(df)
205
197
 
@@ -258,33 +250,26 @@ def load_model(model_name,
258
250
  model_name = str(df['MODEL NAME'].iloc[0])
259
251
  model_type = str(df['MODEL TYPE'].iloc[0])
260
252
  WeightType = str(df['WEIGHTS TYPE'].iloc[0])
261
- layers = list(df['NEURON COUNT'])
262
-
263
- if model_type == 'MLP': max_file = len(layers)-1
264
- else: max_file = 1
265
-
266
- W = []
267
-
268
- for i in range(max_file):
269
-
270
- if WeightType == 'txt':
271
- W.append(np.loadtxt(model_path + model_name + f'weights{i}.txt'))
272
- elif WeightType == 'npy':
273
- W.append(np.load(model_path + model_name + f'weights{i}.npy'))
274
- elif WeightType == 'mat':
275
- W.append(sio.loadmat(model_path + model_name + f'weights{i}.mat'))
276
- elif WeightType == 'pkl':
277
- with open(model_path + model_name + f'weights{i}.pkl', 'rb') as f:
278
- W = pickle.load(f)
279
- else:
280
253
 
281
- raise ValueError(
282
- Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
283
-
284
- if WeightType == 'mat':
285
- W[-1] = W[-1]['w']
286
-
287
- if model_type == 'PLAN': W = np.array(W[0], dtype=W[0].dtype)
254
+ if model_type == 'MLP': allow_pickle = True
255
+ else: allow_pickle = False
256
+
257
+ if WeightType == 'txt':
258
+ W = (np.loadtxt(model_path + model_name + f'_weights.txt'))
259
+ elif WeightType == 'npy':
260
+ W = (np.load(model_path + model_name + f'_weights.npy', allow_pickle=allow_pickle))
261
+ elif WeightType == 'mat':
262
+ W = (sio.loadmat(model_path + model_name + f'_weights.mat'))
263
+ elif WeightType == 'pkl':
264
+ with open(model_path + model_name + f'_weights.pkl', 'rb') as f:
265
+ W = pickle.load(f)
266
+ else:
267
+
268
+ raise ValueError(
269
+ Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
270
+
271
+ if WeightType == 'mat':
272
+ W = W['w']
288
273
 
289
274
  return W, None, None, activation_potentiation, scaler_params, None, model_type
290
275
 
@@ -148,64 +148,56 @@ def save_model(model_name,
148
148
  df = pd.DataFrame(data)
149
149
  df.to_pickle(model_path + model_name + '.pkl')
150
150
 
151
- if isinstance(W, list): max_file = len(W)
152
- else: max_file = 1
153
-
154
- for i in range(max_file):
155
-
156
- if max_file > 1: weight = W[i]
157
- else: weight = W
151
+ try:
158
152
 
159
- try:
153
+ if weights_type == 'txt' and weights_format == 'f':
160
154
 
161
- if weights_type == 'txt' and weights_format == 'f':
155
+ cp.savetxt(model_path + model_name + f'_weights.txt', W, fmt='%f')
162
156
 
163
- cp.savetxt(model_path + model_name + f'weights{i}.txt', weight, fmt='%f')
157
+ if weights_type == 'txt' and weights_format == 'raw':
164
158
 
165
- if weights_type == 'txt' and weights_format == 'raw':
159
+ cp.savetxt(model_path + model_name + f'_weights.txt', W)
166
160
 
167
- cp.savetxt(model_path + model_name + f'weights{i}.txt', weight)
161
+ ###
168
162
 
169
- ###
163
+
164
+ if weights_type == 'pkl' and weights_format == 'f':
170
165
 
171
-
172
- if weights_type == 'pkl' and weights_format == 'f':
166
+ with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
167
+ pickle.dump(W.astype(float), f)
173
168
 
174
- with open(model_path + model_name + f'weights{i}.pkl', 'wb') as f:
175
- pickle.dump(weight.astype(float), f)
169
+ if weights_type == 'pkl' and weights_format =='raw':
170
+
171
+ with open(model_path + model_name + f'_weights.pkl', 'wb') as f:
172
+ pickle.dump(W, f)
176
173
 
177
- if weights_type == 'pkl' and weights_format =='raw':
178
-
179
- with open(model_path + model_name + f'weights{i}.pkl', 'wb') as f:
180
- pickle.dump(weight, f)
174
+ ###
181
175
 
182
- ###
176
+ if weights_type == 'npy' and weights_format == 'f':
183
177
 
184
- if weights_type == 'npy' and weights_format == 'f':
178
+ cp.save(model_path + model_name + f'_weights.npy', W, W.astype(float))
185
179
 
186
- cp.save(model_path + model_name + f'weights{i}.npy', weight, weight.astype(float))
180
+ if weights_type == 'npy' and weights_format == 'raw':
187
181
 
188
- if weights_type == 'npy' and weights_format == 'raw':
182
+ cp.save(model_path + model_name + f'_weights.npy', W)
189
183
 
190
- cp.save(model_path + model_name + f'weights{i}.npy', weight)
184
+ ###
191
185
 
192
- ###
186
+ if weights_type == 'mat' and weights_format == 'f':
193
187
 
194
- if weights_type == 'mat' and weights_format == 'f':
188
+ w = {'w': W.astype(float)}
189
+ io.savemat(model_path + model_name + f'_weights.mat', w)
195
190
 
196
- w = {'w': weight.astype(float)}
197
- io.savemat(model_path + model_name + f'weights{i}.mat', w)
191
+ if weights_type == 'mat' and weights_format == 'raw':
192
+
193
+ w = {'w': W}
194
+ io.savemat(model_path + model_name + f'_weights.mat', w)
198
195
 
199
- if weights_type == 'mat' and weights_format == 'raw':
200
-
201
- w = {'w': weight}
202
- io.savemat(model_path + model_name + f'weights{i}.mat', w)
196
+ except:
203
197
 
204
- except:
198
+ 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)
199
+ sys.exit()
205
200
 
206
- print(Fore.RED + "ERROR: Model Weights not saved. Check the Weight parameters. SaveFilePath expl: 'C:/Users/hasancanbeydili/Desktop/denemePLAN/' from: save_model" + Style.RESET_ALL)
207
- sys.exit()
208
-
209
201
  if show_info:
210
202
  print(df)
211
203
 
@@ -266,33 +258,26 @@ def load_model(model_name,
266
258
  model_name = str(df['MODEL NAME'].iloc[0])
267
259
  model_type = str(df['MODEL TYPE'].iloc[0])
268
260
  WeightType = str(df['WEIGHTS TYPE'].iloc[0])
269
- layers = list(df['NEURON COUNT'])
270
-
271
- if model_type == 'MLP': max_file = len(layers)-1
272
- else: max_file = 1
273
-
274
- W = []
275
-
276
- for i in range(max_file):
277
261
 
278
- if WeightType == 'txt':
279
- W.append(cp.loadtxt(model_path + model_name + f'weights{i}.txt'))
280
- elif WeightType == 'npy':
281
- W.append(cp.load(model_path + model_name + f'weights{i}.npy'))
282
- elif WeightType == 'mat':
283
- W.append(sio.loadmat(model_path + model_name + f'weights{i}.mat'))
284
- elif WeightType == 'pkl':
285
- with open(model_path + model_name + f'weights{i}.pkl', 'rb') as f:
286
- W = pickle.load(f)
287
- else:
288
-
289
- raise ValueError(
290
- Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
291
-
292
- if WeightType == 'mat':
293
- W[-1] = W[-1]['w']
294
-
295
- if model_type == 'PLAN': W = cp.array(W[0], dtype=W[0].dtype)
262
+ if model_type == 'MLP': allow_pickle = True
263
+ else: allow_pickle = False
264
+
265
+ if WeightType == 'txt':
266
+ W = (cp.loadtxt(model_path + model_name + f'_weights.txt'))
267
+ elif WeightType == 'npy':
268
+ W = (cp.load(model_path + model_name + f'_weights.npy', allow_pickle=allow_pickle))
269
+ elif WeightType == 'mat':
270
+ W = (sio.loadmat(model_path + model_name + f'_weights.mat'))
271
+ elif WeightType == 'pkl':
272
+ with open(model_path + model_name + f'_weights.pkl', 'rb') as f:
273
+ W = pickle.load(f)
274
+ else:
275
+
276
+ raise ValueError(
277
+ Fore.RED + "Incorrect weight type value. Value must be 'txt', 'npy', 'pkl' or 'mat' from: load_model." + Style.RESET_ALL)
278
+
279
+ if WeightType == 'mat':
280
+ W = W['w']
296
281
 
297
282
  return W, None, None, activation_potentiation, scaler_params, None, model_type
298
283
 
pyerualjetwork/planeat.py CHANGED
@@ -121,7 +121,7 @@ def evolver(weights,
121
121
  bar_status=True,
122
122
  strategy='normal_selective',
123
123
  bad_genomes_mutation_prob=None,
124
- fitness_bias=1,
124
+ fitness_bias=1,
125
125
  cross_over_mode='tpm',
126
126
  activation_mutate_add_prob=0.5,
127
127
  activation_mutate_delete_prob=0.5,
@@ -129,7 +129,7 @@ def evolver(weights,
129
129
  activation_selection_add_prob=0.5,
130
130
  activation_selection_change_prob=0.5,
131
131
  activation_selection_threshold=20,
132
- activation_mutate_prob=1,
132
+ activation_mutate_prob=0.5,
133
133
  activation_mutate_threshold=20,
134
134
  weight_mutate_threshold=16,
135
135
  weight_mutate_prob=1,
@@ -190,7 +190,7 @@ def evolver(weights,
190
190
  bad_genomes_selection_prob (float, optional): The probability of crossover parents are bad genomes ? [0-1] Default: Determined by `policy`.
191
191
 
192
192
  activation_mutate_prob (float, optional): The probability of applying mutation to the activation functions.
193
- Must be in the range [0, 1]. Default is 1 (%100).
193
+ Must be in the range [0, 1]. Default is 0.5 (%50).
194
194
 
195
195
  cross_over_mode (str, optional): Specifies the crossover method to use. Options:
196
196
  - 'tpm': Two-Point Matrix Crossover.
@@ -129,7 +129,7 @@ def evolver(weights,
129
129
  activation_selection_add_prob=0.5,
130
130
  activation_selection_change_prob=0.5,
131
131
  activation_selection_threshold=20,
132
- activation_mutate_prob=1,
132
+ activation_mutate_prob=0.5,
133
133
  activation_mutate_threshold=20,
134
134
  weight_mutate_threshold=16,
135
135
  weight_mutate_prob=1,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyerualjetwork
3
- Version: 4.6.5
3
+ Version: 4.6.7
4
4
  Summary: PyerualJetwork is a machine learning library supported with GPU(CUDA) acceleration written in Python for professionals and researchers including with PLAN algorithm, PLANEAT algorithm (genetic optimization). Also includes data pre-process and memory manegament
5
5
  Author: Hasan Can Beydili
6
6
  Author-email: tchasancan@gmail.com
@@ -1,4 +1,4 @@
1
- pyerualjetwork/__init__.py,sha256=3t9ZIzCUHWWbL8rfCjLR_LfvzMZswYHymOLkLcH7Cqo,1279
1
+ pyerualjetwork/__init__.py,sha256=qAWAFwiPtMCcyatR3z8bCv1Q33nVY7aqHH7j712tyoc,1279
2
2
  pyerualjetwork/activation_functions.py,sha256=Ms0AGBqkJuCA42ht64MSQnO54Td_1eDGquedpoBDVbc,7642
3
3
  pyerualjetwork/activation_functions_cuda.py,sha256=5y1Ti3GDfDteQDCUmODwe7tAyDAUlDTKmIikChQ8d6g,7772
4
4
  pyerualjetwork/data_operations.py,sha256=Y_RdxkjLEszFgeo4VDWIX1keF2syP-88KesLXA5sRyY,15280
@@ -10,16 +10,16 @@ pyerualjetwork/loss_functions_cuda.py,sha256=C93IZJcrOpT6HMK9x1O4AHJWXYTkN5WZiqd
10
10
  pyerualjetwork/memory_operations.py,sha256=0yCOHcgiNyF4ccMcRlL1Q9F_byG4nzjhmkbpXE_yU6E,13401
11
11
  pyerualjetwork/metrics.py,sha256=q7MkhnZDRbCjFBDDfUgrl8lBYnUT_1ro1LxeBq105pI,6077
12
12
  pyerualjetwork/metrics_cuda.py,sha256=73h9GC7XwmnFCVzFEEiPQfF8CwHIz2wsCbxpZrJtYgw,5061
13
- pyerualjetwork/model_operations.py,sha256=fr64XCwgl1YRh5nP3sEkvQORKHb-2lF_a4KjclNkZfY,15522
14
- pyerualjetwork/model_operations_cuda.py,sha256=-Kv8fYqHSU0L9FalOsQ7EWCwCEwjgUySObyueOqCH_o,16134
13
+ pyerualjetwork/model_operations.py,sha256=KaJS2IM5Uk527DqN2ENdKX99yJElymfTmE3226j2HwM,14941
14
+ pyerualjetwork/model_operations_cuda.py,sha256=0MyokoskDTnMKugu4kU8PP4F5tLN6RYNUx_5SWvqoyg,15562
15
15
  pyerualjetwork/plan.py,sha256=UyIvPmvHCHwczlc9KHolE4y6CPEeBfhnRN5yznSbnoM,23028
16
16
  pyerualjetwork/plan_cuda.py,sha256=iteqgv7x9Z2Pj4vGOZs6HXS3r0bNaF_smr7ZXaOdRnw,23990
17
- pyerualjetwork/planeat.py,sha256=fQYSTzp304TES0bI_oLWSsvXnZ6YRUjVHlXsfBv9WwM,44643
18
- pyerualjetwork/planeat_cuda.py,sha256=O62BzwykdoMtf1y6FQxvZ47bvNdHoj5BWmGcRjM_Aaw,44648
17
+ pyerualjetwork/planeat.py,sha256=prbkUIrD37Y_b7MmTuGg4rGHXfqHIjLFMbs7TnnEy9E,44645
18
+ pyerualjetwork/planeat_cuda.py,sha256=i6WDHkUEAMK7IHNBilM29xyYWq2qvPNpF9idcAkC1EU,44650
19
19
  pyerualjetwork/ui.py,sha256=JBTFYz5R24XwNKhA3GSW-oYAoiIBxAE3kFGXkvm5gqw,656
20
20
  pyerualjetwork/visualizations.py,sha256=utnX9zQhzmtvBJLOLNGm2jecVVk4zHXABQdjb0XzJac,28352
21
21
  pyerualjetwork/visualizations_cuda.py,sha256=gnoaaazZ-nc9E1ImqXrZBRgQ4Rnpi2qh2yGJ2eLKMlE,28807
22
- pyerualjetwork-4.6.5.dist-info/METADATA,sha256=RTxs6Gl-cLg0EtKG5FgHQHKs8abncHww-GT1oR3XBSg,7505
23
- pyerualjetwork-4.6.5.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
- pyerualjetwork-4.6.5.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
25
- pyerualjetwork-4.6.5.dist-info/RECORD,,
22
+ pyerualjetwork-4.6.7.dist-info/METADATA,sha256=191yqow3K5p68q4nmtWhIx95BDSOSj-xlwcT7w6Tmms,7505
23
+ pyerualjetwork-4.6.7.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
+ pyerualjetwork-4.6.7.dist-info/top_level.txt,sha256=BRyt62U_r3ZmJpj-wXNOoA345Bzamrj6RbaWsyW4tRg,15
25
+ pyerualjetwork-4.6.7.dist-info/RECORD,,