From 4733de37731866e4e137da679012bfca961876b9 Mon Sep 17 00:00:00 2001 From: Csaba Toth Date: Tue, 29 Aug 2023 14:31:35 -0700 Subject: [PATCH 1/4] Adding prints to text_generation_using_transformers Training Fixes #388 --- .../labs/text_generation_using_transformers.ipynb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/notebooks/text_models/labs/text_generation_using_transformers.ipynb b/notebooks/text_models/labs/text_generation_using_transformers.ipynb index 5264d493..5c026756 100644 --- a/notebooks/text_models/labs/text_generation_using_transformers.ipynb +++ b/notebooks/text_models/labs/text_generation_using_transformers.ipynb @@ -422,9 +422,17 @@ "outputs": [], "source": [ "EPOCHS = 1 # increase the number of epochs for better results\n", + "print(\"Training started, this could take 4-10 mins per epoch with a T4 GPU...\")\n", + "vocab = keras_nlp.tokenizers.compute_word_piece_vocabulary(\n", + " raw_train_ds,\n", + " vocabulary_size=VOCAB_SIZE,\n", + " lowercase=True,\n", + " reserved_tokens=[\"[PAD]\", \"[UNK]\", \"[BOS]\"],\n", + ")\n", "model.fit(\n", " # TODO: Fill out the arguments\n", - ")" + ")\n", + "print(\"Training is complete!!\")" ] }, { From 76a96639ea8dfa62b4718e2d8c6ab4684d6a927c Mon Sep 17 00:00:00 2001 From: Csaba Toth Date: Tue, 29 Aug 2023 14:37:20 -0700 Subject: [PATCH 2/4] Remove copy-paste leftover from #388 fix --- .../labs/text_generation_using_transformers.ipynb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/notebooks/text_models/labs/text_generation_using_transformers.ipynb b/notebooks/text_models/labs/text_generation_using_transformers.ipynb index 5c026756..4545c292 100644 --- a/notebooks/text_models/labs/text_generation_using_transformers.ipynb +++ b/notebooks/text_models/labs/text_generation_using_transformers.ipynb @@ -104,7 +104,7 @@ "outputs": [], "source": [ "# this should output \"Num GPUs Available: 1\" if you have one GPU attached\n", - "print(\"Num GPUs Available: \", len(tf.config.list_physical_devices(\"GPU\")))" + "\"Num GPUs Available: \", len(tf.config.list_physical_devices(\"GPU\")))" ] }, { @@ -221,7 +221,7 @@ "outputs": [], "source": [ "# Train tokenizer vocabulary\n", - "print(\"Training the word piece tokenizer. This will take 5-10 mins...\")\n", + "\"Training the word piece tokenizer. This will take 5-10 mins...\")\n", "vocab = keras_nlp.tokenizers.compute_word_piece_vocabulary(\n", " raw_train_ds,\n", " vocabulary_size=VOCAB_SIZE,\n", @@ -423,12 +423,6 @@ "source": [ "EPOCHS = 1 # increase the number of epochs for better results\n", "print(\"Training started, this could take 4-10 mins per epoch with a T4 GPU...\")\n", - "vocab = keras_nlp.tokenizers.compute_word_piece_vocabulary(\n", - " raw_train_ds,\n", - " vocabulary_size=VOCAB_SIZE,\n", - " lowercase=True,\n", - " reserved_tokens=[\"[PAD]\", \"[UNK]\", \"[BOS]\"],\n", - ")\n", "model.fit(\n", " # TODO: Fill out the arguments\n", ")\n", From 9cb9bd98a9abfbfa76a846f2c818a9d302beb981 Mon Sep 17 00:00:00 2001 From: Csaba Toth Date: Tue, 29 Aug 2023 14:37:53 -0700 Subject: [PATCH 3/4] Same #388 changes to the solution text_generation_using_transformers.ipynb --- .../solutions/text_generation_using_transformers.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notebooks/text_models/solutions/text_generation_using_transformers.ipynb b/notebooks/text_models/solutions/text_generation_using_transformers.ipynb index 4758be18..7de985c7 100644 --- a/notebooks/text_models/solutions/text_generation_using_transformers.ipynb +++ b/notebooks/text_models/solutions/text_generation_using_transformers.ipynb @@ -401,7 +401,9 @@ "outputs": [], "source": [ "EPOCHS = 1 # increase the number of epochs for better results\n", - "model.fit(train_ds, validation_data=val_ds, verbose=2, epochs=EPOCHS)" + "print(\"Training started, this could take 4-10 mins per epoch with a T4 GPU...\")\n", + "model.fit(train_ds, validation_data=val_ds, verbose=2, epochs=EPOCHS)\n", + "print(\"Training is complete!!\")" ] }, { From acf60e8c0b2f6e56510711fa5eb9324c81549e69 Mon Sep 17 00:00:00 2001 From: Csaba Toth Date: Tue, 29 Aug 2023 14:40:00 -0700 Subject: [PATCH 4/4] Correct accidentally removed prints --- .../text_models/labs/text_generation_using_transformers.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebooks/text_models/labs/text_generation_using_transformers.ipynb b/notebooks/text_models/labs/text_generation_using_transformers.ipynb index 4545c292..4b5eb917 100644 --- a/notebooks/text_models/labs/text_generation_using_transformers.ipynb +++ b/notebooks/text_models/labs/text_generation_using_transformers.ipynb @@ -104,7 +104,7 @@ "outputs": [], "source": [ "# this should output \"Num GPUs Available: 1\" if you have one GPU attached\n", - "\"Num GPUs Available: \", len(tf.config.list_physical_devices(\"GPU\")))" + "print(\"Num GPUs Available: \", len(tf.config.list_physical_devices(\"GPU\")))" ] }, { @@ -221,7 +221,7 @@ "outputs": [], "source": [ "# Train tokenizer vocabulary\n", - "\"Training the word piece tokenizer. This will take 5-10 mins...\")\n", + "print(\"Training the word piece tokenizer. This will take 5-10 mins...\")\n", "vocab = keras_nlp.tokenizers.compute_word_piece_vocabulary(\n", " raw_train_ds,\n", " vocabulary_size=VOCAB_SIZE,\n",