Skip to content

Commit 8939f3c

Browse files
Update phishing_email_detection_gpt2.py
Test with default params with AdamW.
1 parent 0eab09e commit 8939f3c

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

phishing_email_detection_gpt2.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585

8686
"""### A custom GPT2 encoder layer for text embedding"""
8787

88+
"""
8889
8990
class GPT2Layer(tf.keras.layers.Layer):
9091
@@ -183,6 +184,7 @@ def from_config(cls, config):
183184
hy_df = pd.DataFrame(history.history)
184185
print(hy_df)
185186
187+
"""
186188

187189
### Cerebros model:
188190

@@ -248,17 +250,6 @@ def from_config(cls, config):
248250
)
249251

250252

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-
262253
"""### Cerebros search for the best model"""
263254

264255
#
@@ -352,20 +343,11 @@ def from_config(cls, config):
352343
cerebros_time_per_model = cerebros_time_all_models_min / models_tried
353344

354345
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.")
356347

357348

358349
print(f'Cerebros best accuracy achieved is {result}')
359350
print(f'val set accuracy')
360351

361352
# """### Testing the best model found"""
362353

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

Comments
 (0)