Week 2 Quiz :Natural Language Processing in TensorFlow (DeepLearning.AI TensorFlow Developer Professional Certificate) Answers 2025
1. Question 1
To use word embeddings in TensorFlow, which layer is used?
-
❌ tf.keras.layers.Embed
-
✅ tf.keras.layers.Embedding
-
❌ tf.keras.layers.Word2Vector
-
❌ tf.keras.layers.WordEmbedding
Explanation:tf.keras.layers.Embedding is the correct and only embedding layer in Keras.
2. Question 2
Using default settings, what does max_tokens do in TextVectorization?
-
❌ max_tokens − 2
-
❌ max_tokens
-
❌ errors out
-
✅ It specifies the maximum vocabulary size and picks the most common max_tokens − 1 words
Explanation:TextVectorization reserves 1 token for OOV, so actual vocab = max_tokens - 1 plus OOV token.
3. Question 3
What is the name of TensorFlow’s library of common datasets?
-
❌ TensorFlow Data
-
❌ No library exists
-
❌ TensorFlow Data Libraries
-
✅ TensorFlow Datasets
Explanation:tfds (TensorFlow Datasets) provides ready-made datasets like MNIST, IMDB, CIFAR-10.
4. Question 4
Purpose of the embedding dimension?
-
❌ Number of dimensions required to encode every word
-
❌ Number of words to encode
-
❌ Number of letters in the word
-
✅ Number of dimensions in the vector representing each word
Explanation:
Embedding dimension = size of each word vector (e.g., 16, 32, 128).
5. Question 5
IMDB Reviews → positive or negative. Which loss function?
-
❌ Binary Gradient Descent
-
❌ Adam
-
❌ Categorical crossentropy
-
✅ Binary crossentropy
Explanation:
Binary classification → binary crossentropy.
6. Question 6
How are IMDB labels encoded?
-
❌ 0–1 range reviews
-
❌ True/false booleans
-
❌ 1–5 ratings
-
❌ 1–10 ratings
Correct Answer:
✅ Reviews are encoded as integers: 0 = negative, 1 = positive
Explanation:
IMDB dataset labels are 0 or 1, representing sentiment.
7. Question 7
How many reviews are in IMDB and how are they split?
-
❌ 60,000 — 50/50
-
❌ 50,000 — 80/20
-
❌ 60,000 — 80/20
-
✅ 50,000 — 50/50 split
Explanation:
IMDB dataset contains 25,000 training + 25,000 testing reviews.
🧾 Summary Table
| Q# | Correct Answer | Key Concept |
|---|---|---|
| 1 | Embedding layer | Word embeddings |
| 2 | max_tokens − 1 vocab | TextVectorization behavior |
| 3 | TensorFlow Datasets | Prebuilt datasets |
| 4 | Vector dimensions | Meaning of embedding size |
| 5 | Binary crossentropy | Binary sentiment task |
| 6 | Labels are 0 (neg) / 1 (pos) | IMDB encoding |
| 7 | 50,000 reviews, 50/50 split | Dataset structure |