Skip to content

Commit c754bc1

Browse files
Merge pull request #2245 from 8bitmp3:upda-warmstart-embedding
PiperOrigin-RevId: 548822493
2 parents 37bb665 + 1ae390a commit c754bc1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

site/en/tutorials/text/warmstart_embedding_matrix.ipynb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"source": [
9292
"### Vocabulary\n",
9393
"\n",
94-
"The set of unique words is referred to as the vocabulary. To build a text model you need to choose a fixed vocabulary. Typically you you build the vocabulary from the most common words in a dataset. The vocabulary allows us to represent each piece of text by a sequence of ID's that you can lookup in the embedding matrix. Vocabulary allows us to represent each piece of text by the specific words that appear in it."
94+
"The set of unique words is referred to as the vocabulary. To build a text model you need to choose a fixed vocabulary. Typically you build the vocabulary from the most common words in a dataset. The vocabulary allows us to represent each piece of text by a sequence of ID's that you can lookup in the embedding matrix. Vocabulary allows us to represent each piece of text by the specific words that appear in it."
9595
]
9696
},
9797
{
@@ -104,7 +104,7 @@
104104
"\n",
105105
"A model is trained with a set of embeddings that represents a given vocabulary. If the model needs to be updated or improved you can train to convergence significantly faster by reusing weights from a previous run. Using the embedding matrix from a previous run is more difficult. The problem is that any change to the vocabulary invalidates the word to id mapping.\n",
106106
"\n",
107-
"The `tf.keras.utils.warmstart_embedding_matrix` solves this problem by creating an embedding matrix for a new vocabulary from an embedding martix from a base vocabulary. Where a word exists in both vocabularies the base embedding vector is copied into the correct location in the new embedding matrix. This allows you to warm-start training after any change in the size or order of the vocabulary."
107+
"The `tf.keras.utils.warmstart_embedding_matrix` solves this problem by creating an embedding matrix for a new vocabulary from an embedding matrix from a base vocabulary. Where a word exists in both vocabularies the base embedding vector is copied into the correct location in the new embedding matrix. This allows you to warm-start training after any change in the size or order of the vocabulary."
108108
]
109109
},
110110
{
@@ -155,7 +155,7 @@
155155
},
156156
"source": [
157157
"### Load the dataset\n",
158-
"The tutorial uses the [Large Movie Review Dataset](http://ai.stanford.edu/~amaas/data/sentiment/). You will train a sentiment classifier model on this dataset and in the process learn embeddings from scratch. Refer to [Loading text tutorial](https://www.tensorflow.org/tutorials/load_data/text) to learn more. \n",
158+
"The tutorial uses the [Large Movie Review Dataset](http://ai.stanford.edu/~amaas/data/sentiment/). You will train a sentiment classifier model on this dataset and in the process learn embeddings from scratch. Refer to the [Loading text tutorial](https://www.tensorflow.org/tutorials/load_data/text) to learn more. \n",
159159
"\n",
160160
"Download the dataset using Keras file utility and review the directories."
161161
]
@@ -184,7 +184,7 @@
184184
"id": "eY6yROZNKvbd"
185185
},
186186
"source": [
187-
"The `train/` directory has `pos` and `neg` folders with movie reviews labelled as positive and negative respectively. You will use reviews from `pos` and `neg` folders to train a binary classification model."
187+
"The `train/` directory has `pos` and `neg` folders with movie reviews labeled as positive and negative respectively. You will use reviews from `pos` and `neg` folders to train a binary classification model."
188188
]
189189
},
190190
{
@@ -715,7 +715,7 @@
715715
"source": [
716716
"You have successfully updated the model to accept a new vocabulary. The embedding layer is updated to map old vocabulary words to old embeddings and initialize embeddings for new vocabulary words to be learnt. The learned weights of the rest of the model will remain the same. The model is warm-started to continue to train from where it left off previously.\n",
717717
"\n",
718-
"You can now verify that the remapping worked. Get index of the vocabulary word \"the\" that is present both in base and new vocabulary and compare the embedding values. They should be equal."
718+
"You can now verify that the remapping worked. Get the index of the vocabulary word \"the\" that is present both in base and new vocabulary and compare the embedding values. They should be equal."
719719
]
720720
},
721721
{
@@ -745,7 +745,7 @@
745745
"source": [
746746
"## Continue with warm-started training\n",
747747
"\n",
748-
"Notice how the training is warm-started. The accuracy of first epoch is around 85%. Close to the accuracy where the previous traning ended."
748+
"Notice how the training is warm-started. The accuracy of first epoch is around 85%. This is close to the accuracy where the previous training ended."
749749
]
750750
},
751751
{
@@ -823,7 +823,6 @@
823823
"colab": {
824824
"collapsed_sections": [],
825825
"name": "warmstart_embedding_matrix.ipynb",
826-
"provenance": [],
827826
"toc_visible": true
828827
},
829828
"kernelspec": {

0 commit comments

Comments
 (0)