Skip to content

Week 1 Quiz :Natural Language Processing in TensorFlow (DeepLearning.AI TensorFlow Developer Professional Certificate) Answers 2025

1. Question 1

In the lectures, what is the name of the layer used to generate the vocabulary?

  • ❌ Tokenizer

  • ❌ TextTokenizer

  • ❌ WordTokenizer

  • ✅ TextVectorization

Explanation: TensorFlow’s TextVectorization layer builds the vocabulary and vectorizes text.


2. Question 2

Once you have generated a vocabulary, how do you encode a sentence into an integer sequence?

  • ✅ Pass the string to the adapted TextVectorization layer.

  • ❌ get_vocabulary()

  • ❌ texts_to_tokens()

  • ❌ texts_to_sequences()

Explanation: The TextVectorization layer itself is callable.
Usage:

vectorize_layer("this is a sentence")

3. Question 3

How do you handle sequences of different lengths?

  • ✅ Use the pad_sequences function from tf.keras.utils

  • ❌ pad_sequences method inside TextVectorization

  • ❌ pad_sequences property on input layer

  • ❌ dynamic_length input layer

Explanation: Use tf.keras.utils.pad_sequences() to ensure equal sequence length.


4. Question 4

What happens when encoding a word not in the vocabulary?

  • ❌ Sequencing ends

  • ❌ Replaced by most common token

  • ✅ An out-of-vocabulary token (OOV token) is used

  • ❌ Replaced by zero

Explanation: OOV token (usually index 1) represents unknown words.


5. Question 5

How to pad at the end of a sequence?

  • padding='post' in pad_sequences

  • ❌ padding=’after’

  • ❌ padding method with ‘after’

  • ❌ padding method with ‘post’

Explanation:

pad_sequences(..., padding='post')

6. Question 6

Convert a list of strings into integer sequences?

  • ❌ vectorize_layer.fit(sentences)

  • ❌ vectorize_layer.tokenize(sentences)

  • ❌ vectorize_layer.fit_to_text(sentences)

  • ✅ vectorize_layer(sentences)

Explanation: Call the layer directly to vectorize text.


7. Question 7

Default behavior of pad_sequences?

  • ✅ Pad to the longest sequence by adding zeros at the beginning

  • ❌ Pad zeros at the end

  • ❌ Leave unchanged

  • ❌ Crop to shortest

Explanation: Default is:

padding='pre'
truncating='pre'

8. Question 8

How does TextVectorization standardize strings by default?

  • ❌ Stripping punctuation

  • ❌ Alphabetical order

  • ❌ Lowercasing only

  • ✅ Lowercasing AND stripping punctuation

Explanation: Default standardization = lower_and_strip_punctuation.


🧾 Summary Table

Q# Correct Answer Key Concept
1 TextVectorization Builds vocabulary
2 vectorize_layer(string) Encodes text
3 pad_sequences Making sequences equal length
4 OOV token Handling unknown words
5 padding=’post’ Post-padding
6 vectorize_layer(sentences) Convert list of strings
7 Pad with zeros at beginning Default pad_sequences behavior
8 lowercase + strip punctuation Default standardization