Skip to content

Commit 3b9ffc0

Browse files
Update phishing_email_detection_gpt2.py
Add back the baseline GPT2 task.
1 parent 783368e commit 3b9ffc0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

phishing_email_detection_gpt2.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
99
## GPT2 + Cerebros for Phishing email detection
1010
11-
Initialization
12-
def rotate_half(x):
13-
x = split_alternate(x)
14-
rotated_x = tf.concat([-x[..., x.shape[-1]//2:], x[..., :x.shape[-1]//2]], axis=-1)
15-
return tf.reshape(rotated_x, tf.shape(x))"""
1611
1712
import tensorflow as tf
1813
import tensorflow_text
@@ -89,7 +84,7 @@ def rotate_half(x):
8984
9085
"""### A custom GPT2 encoder layer for text embedding"""
9186

92-
"""
87+
9388
class GPT2Layer(tf.keras.layers.Layer):
9489

9590
def __init__(self, max_seq_length, **kwargs):
@@ -187,7 +182,7 @@ def from_config(cls, config):
187182
hy_df = pd.DataFrame(history.history)
188183
print(hy_df)
189184

190-
"""
185+
191186

192187
### Cerebros model:
193188

@@ -526,7 +521,7 @@ def from_config(cls, config):
526521
cerebros_time_per_model = cerebros_time_all_models_min / models_tried
527522

528523
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.")
529-
# print(f"GPT2 took {gpt_time_on_one_model_min} just to FINE TUNE one PRE - TRAINED model for 3 epochs. Although this is a small scale test, this shows the advantage of scaling in ON timing VS ON**2 timing.")
524+
print(f"GPT2 took {gpt_time_on_one_model_min} just to FINE TUNE one PRE - TRAINED model for 3 epochs. Although this is a small scale test, this shows the advantage of scaling in ON timing VS ON**2 timing.")
530525

531526

532527
print(f'Cerebros best accuracy achieved is {result}')

0 commit comments

Comments
 (0)