|
85 | 85 |
|
86 | 86 | """### A custom GPT2 encoder layer for text embedding""" |
87 | 87 |
|
| 88 | +""" |
88 | 89 |
|
89 | 90 | class GPT2Layer(tf.keras.layers.Layer): |
90 | 91 |
|
@@ -183,6 +184,7 @@ def from_config(cls, config): |
183 | 184 | hy_df = pd.DataFrame(history.history) |
184 | 185 | print(hy_df) |
185 | 186 |
|
| 187 | +""" |
186 | 188 |
|
187 | 189 | ### Cerebros model: |
188 | 190 |
|
@@ -248,17 +250,6 @@ def from_config(cls, config): |
248 | 250 | ) |
249 | 251 |
|
250 | 252 |
|
251 | | - |
252 | | - |
253 | | - |
254 | | -# dropout_embedded = tf.keras.layers.Dropout(0.6)(embedded) |
255 | | -# flattened = tf.keras.layers.Flatten()(dropout_embedded) |
256 | | - |
257 | | -# cerebros_base_model =\ |
258 | | -# tf.keras.Model( |
259 | | -# inputs=inp, |
260 | | -# outputs=flattened) |
261 | | - |
262 | 253 | """### Cerebros search for the best model""" |
263 | 254 |
|
264 | 255 | # |
@@ -352,20 +343,11 @@ def from_config(cls, config): |
352 | 343 | cerebros_time_per_model = cerebros_time_all_models_min / models_tried |
353 | 344 |
|
354 | 345 | print(f"Cerebros trained {models_tried} models FROM A COLD START in ONLY {cerebros_time_all_models_min} min. Cerebros took only {cerebros_time_per_model} minutes on average per model.") |
355 | | -print(f"GPT2 took {gpt_time_on_one_model_min} just to FINE TUNE one PRE - TRAINED model. Although this is a small scale test, this shows the advantage of scaling in ON timing VS ON**2 timing.") |
| 346 | +# print(f"GPT2 took {gpt_time_on_one_model_min} just to FINE TUNE one PRE - TRAINED model. Although this is a small scale test, this shows the advantage of scaling in ON timing VS ON**2 timing.") |
356 | 347 |
|
357 | 348 |
|
358 | 349 | print(f'Cerebros best accuracy achieved is {result}') |
359 | 350 | print(f'val set accuracy') |
360 | 351 |
|
361 | 352 | # """### Testing the best model found""" |
362 | 353 |
|
363 | | -# # |
364 | | -# # Load the best model (taking into account that it has a custom layer) |
365 | | -# # |
366 | | -# best_model_found =\ |
367 | | -# tf.keras.models.load_model(cerebros_automl.best_model_path,\ |
368 | | -# custom_objects={'GPT2Layer': GPT2Layer(max_seq_length)}) |
369 | | - |
370 | | -# print('Evaluating on the test dataset') |
371 | | -# best_model_found.evaluate(X_test, y_test) |
0 commit comments